AngularJS filter comparator true while displaying ng-repeat list when input field is empty

前端 未结 1 555
有刺的猬
有刺的猬 2021-01-03 05:41

I\'m going off by this example fiddle where it demonstrates the use of comparator parameter to filter exact matches....:

http://jsfiddle.net/api/post/library/pure/

1条回答
  •  不知归路
    2021-01-03 06:01

    You'll want to use a custom comparator function. It will allow you to perform a strict comparison except when the predicate is falsy.

    Your markup would then be:

     
    
    
     {{workflowItem.priority}}
    

    And define the comparator function on your controller:

    $scope.exceptEmptyComparator = function (actual, expected) {
        if (!expected) {
           return true;
        }
        return angular.equals(expected, actual);
    }
    

    That should do the trick.

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