简体   繁体   中英

How do I filter a ng-repeat by a boolean attribute in Angular.Dart?

Each space is an object with a boolean attribute called open , and I'm putting them into two lists. In this case, I have two of them, one is true and one is false . When the list renders at all, both items are in the open list. Here's what I've tried:

ng-repeat="space in ctrl.manager.spaces | filter:open"
ng-repeat="space in ctrl.manager.spaces | filter:!open"

and

ng-repeat="space in ctrl.manager.spaces | filter:open:true"
ng-repeat="space in ctrl.manager.spaces | filter:open:false"

and

ng-repeat="space in ctrl.manager.spaces | filter:{'open':true}"
ng-repeat="space in ctrl.manager.spaces | filter:{'open':false}"

{{space.open}} confirms that one is true and one is false .

The correct way to apply this filter is

ng-repeat="item in items | filter: {open: 'true'}
ng-repeat="item in items | filter: {open: '!true'}

(put the 'true' in quotes)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM