首页 > Web开发 > 详细

AngularJs学习之一使用自定义的过滤器

时间:2016-08-27 22:04:36      阅读:280      评论:0      收藏:0      [点我收藏+]
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学习之一使用自定义的过滤器

原文:http://www.cnblogs.com/yansum/p/5813741.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!