I have a json file with keys like
[
{
"message": "Verify envelopes are properly loaded.",
"hasFigure": false,
"figureX": 0,
"figureY": 0
},
{
"message": "Verify the paddle is in the down position.",
"hasFigure": true,
"figureX": 185,
"figureY": 50
}
]
I need to put this into an ng-repeat but only show the items where hasFigure
is true
I know it's a filter, but can't seem to get the syntax...
Your filter syntax would be
For safer side use strict checking by adding
: true
at the end of filter
<div ng-repeat="item in items | filter: {'hasFigure': true}: true"></div>
为什么不使用ng-show
/ ng-hide
<div ng-repeat="item in items" ng-show="item.hasFigure"></div>
您是否尝试过以下方法:
<div ng-repeat="stuff in stuffs | filter: { hasFigure: true }">
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.