我是angular的新手,我想在html视图的filter语句中使用scope variable属性,如下所示:
<li ng-repeat="item in allItems | filter:{property: !currentItem.property}">{{item.property}}</li>
在这里,我想从项目列表中排除已显示的项目:currentItem
。
但它似乎不适合我,我得到一个空列表。
我可以使用过滤功能实现它:
$scope.exceptCurrentItem = function(anItem) {
return anItem.property != $scope.currentItem.property;
}
我想知道的是,为什么第一种方法对我不起作用?
答案 0 :(得分:1)
如果您不想使用过滤器表达式,可以使用简单的ng-if。
我在这里创建了一个plnkr: https://plnkr.co/edit/mlrxoLUoTuwJaKmsW5IU?p=preview
<li ng-repeat="item in allItems"
ng-if="item.property != myItem.property">{{item.property}}</li>
答案 1 :(得分:0)
请在js文件中使用jquery过滤器。
com.codename1.io.Socket