I want to display a list of shops in an unordered list. I want to exclude "currentShop" from all shops. I wrote something like:
<ul class="dropdown-menu dropdown-menu-default">
<li ng-repeat="shop in user.account.shops | filter:!currentShop}">
<a href="#/profile">
<i class="icon-user"></i> {{shop.name}} </a>
</li>
</ul>
Where am I wrong?
AngularJS Filters filter Select a subset of items from an array. json Format an object to a JSON string. limitTo Limits an array/string, into a specified number of elements/characters. lowercase Format a string to lower case.
Filters are used for formatting data displayed to the user. They can be used in view templates, controllers or services. AngularJS comes with a collection of built-in filters, but it is easy to define your own as well.
Introduction to AngularJS Custom Filter. In AngularJS filters are used to modify or update the data before rendering the data on view or UI. Filters are clubbed in expression or directives using pipe (|) symbol.
The ng-repeat values can be filtered according to the ng-model in AngularJS by using the value of the input field as an expression in a filter. We can set the ng-model directive on an input field to filter ng-repeat values.
Here you have a working example. You can filter by a scope
expression
ng-repeat="item in list | filter: myExpression"
Define your filter function;
$scope.myExpression= function(shop) {
return shop.id !== $scope.current.id;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With