简体   繁体   English

在ng-repeat中使用过滤器

[英]Using filter in ng-repeat

I am trying to use a filter with an expression in ng-repeat like this - 我试图在ng-repeat中使用带有表达式的过滤器,如下所示 -

<div ng-repeat= "fruit in fruits | filter: {fruit.color !: 'red'}">
   {{ fruit }}
</div>

But it doesn't seem to work, can someone confirm that it is possible to use expression in filters(I am using angular 1.0.8) 但它似乎不起作用,有人可以确认可以在过滤器中使用表达式(我使用角度1.0.8)

First thing you should upgrade you Angular Version to latest, it would not make sense to stay with Angular 1.0.x 首先你应该将Angular版本升级到最新版本,继续使用Angular 1.0.x是没有意义的

<div ng-repeat= "fruit in fruits | filter: {color : '!' + selected Color}">
   {{ fruit }}
</div>

This is just example of filter in ng-repeat: 这只是ng-repeat中过滤器的示例:

<div ng-repeat= "fruit in fruits" >
     {{ fruit | uppercase}} 
</div>

$scope.fruits  = ['apple','banana']

OutPut: 输出:

APPLE
BANANA

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM