首页 > 代码库 > AngularJs学习之一使用自定义的过滤器
AngularJs学习之一使用自定义的过滤器
script:参数item是由AngularJs提供的,是应当被过滤的对象集合。而showComplete是我们传入的参数。{{item.action}}用ng-model创造一个名为showComplete的数据script:<script type="text/javascript">// <![CDATA[todoApp.filter("checkedItems",function(){ return function (items,showComplete){ var resultArr =[]; angular.forEach(items,function(item){ if(item.done==false||showComplete==true){ resultArr.push(item); } }); return resultArr; }});//</script><p>参数item是由AngularJs提供的,是应当被过滤的对象集合。而showComplete是我们传入的参数。</p><p>{{item.action}}</p>
<tr ng-repeat="item in todo.items|checkedItems:showComplete|orderBy:‘action‘">
<td>{{item.action}}</td>
</tr>
用ng-model创造一个名为showComplete的数据模型值。<lable><input type="checkbox" ng-model="showComplete">show complete</input></lable> show complete
AngularJs学习之一使用自定义的过滤器
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。