6

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?

4
  • Try !'currentShop' Commented Apr 8, 2015 at 20:00
  • I believe you want the ! in the quotes. Although it depends on what currentShop is I suppose. docs.angularjs.org/api/ng/filter/filter Commented Apr 8, 2015 at 20:13
  • @burak is currentShop a object or just string .. name of shop ? Commented Apr 8, 2015 at 20:20
  • It's an object @sylwester Commented Apr 9, 2015 at 5:48

1 Answer 1

7

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;
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.