Angular.js: filter ng-repeat by absence in array

后端 未结 1 1046
孤城傲影
孤城傲影 2021-02-13 22:47

I need to filter items in ng-repeat so that only the items which not appear in alreadyAddedValues() array will be shown:

    &
相关标签:
1条回答
  • 2021-02-13 23:07

    You can, for example, use a custom function to do the filtering:

    <li ng-repeat="v in values() | filter:filterAlreadyAdded ">{{value.name}}</li>
    

    On the controller:

    $scope.filterAlreadyAdded = function(item) {
        // filter logic here...
        // return false if item already added, true otherwise
    };
    

    jsfiddle: http://jsfiddle.net/bmleite/5VbCJ/

    0 讨论(0)
提交回复
热议问题