androberz androberz - 21 days ago 4x
AngularJS Question

Filter by property of $scope var in a view

I'm new to angular, and I wanted to use scope variable property in the filter statement in the html view like the following:

<li ng-repeat="item in allItems | filter:{property: !}">{{}}</li>

Here I want to exclude from list of items the item that already displayed:
But it seems not working for me and I get an empty list.

I was able to implement it by using the filter function:

$scope.exceptCurrentItem = function(anItem) {
return != $;

What I would like to know, why the first approach is not working for me?


If you don't want to use a filter expression you can use a simple ng-if.

I've created a plnkr here:

<li ng-repeat="item in allItems" 
ng-if=" !=">{{}}</li>