ng-repeat filter on boolean

前端 未结 5 1823
再見小時候
再見小時候 2021-02-02 05:16

I am trying to filter on a boolean value in an ng-repeat.

List of unregistered users:

    

Unregistered Users

5条回答
  •  执念已碎
    2021-02-02 05:48

    In case an item does not have a boolean property set, you can find the item with a property not set to true by using '!' with quotes. e.x. filter: {property:'!'+true}.

    Example:

    $scope.users = [
            {
                name : 'user1 (registered)',
                registered : true
            },
            {
                name : 'user2 (unregistered)'
            },
            {
                name : 'user3 (registered)',
                registered : true
            },
             {
                name : 'user4 (unregistered)'
            }
    

    To get unregistered users filter:

    Unregistered Users

    {{user.name}}

提交回复
热议问题