星空网 > 软件开发 > Java

angularjs过滤器

 

  • 在html文件中和在js文件中使用
$scope.form_time = $filter('date')($scope.time, 'yyyy-MM-dd HH:mm:ss');<p>{{time | date: 'yyyy-MM-dd HH:mm:ss'}}</p>

 

  • 内部过滤器和自定义过滤器

    

.filter('my_data_format',[function(){  return function(data,str,sss){    console.log('data: ',data,' str: ',str,' sss: ',arguments[2]);  }}]);//var1就是第一个参数data, 123是第二个参数str, this是第三个参数<p>{{var1 | my_data_format : 123 : 'this'}}</p>//对传入的数据进行处理.filter('my_data_format',[function(){  return function(data,str){    var arr=[];    angular.forEach(data, function(one_list){      if(one_list.status == str){        arr.push(one_list);      }    });    return arr;  }}]);//过滤器可以用在绑定的值中,也可以用在ng-if="(lists | my_data_format: '2').length>0", 和ng-show等;类似的表达式中。作为判断语句<p ng-repeat = "list in lists">姓名:{{list.name}},人数{{(lists | my_data_format: '2').length}}</p>

 




原标题:angularjs过滤器

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

东莞到海口专线物流:https://www.goluckyvip.com/tag/97983.html
东莞至海南物流专线:https://www.goluckyvip.com/tag/97984.html
中国越南专线:https://www.goluckyvip.com/tag/97985.html
苏州到越南专线:https://www.goluckyvip.com/tag/97986.html
东莞到南阳专线物流:https://www.goluckyvip.com/tag/97987.html
东莞至物流专线专线:https://www.goluckyvip.com/tag/97988.html
三亚有哪些酒店值得入住?:https://www.vstour.cn/a/366173.html
零售晚报:丽人丽妆2023年扭亏为盈 玉容初、美壹堂等自有品牌增速超40% :https://www.kjdsnews.com/a/1836649.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流