I have an object with a series of object properties that is in the following similar structure (which is the way the data is coming back from a service):
{
"1": {
"type": "foo",
"name": "blah"
},
"2": {
"type": "bar"
},
"3": {
"type": "foo"
},
"4": {
"type": "baz"
},
"5": {
"type": "test"
}
}
When I do a ng-repeat, I can iterate over all 5 of these object, something like:
<div ng-repeat="item in items">{{item.type}}</div>
However, what I really want to do is iterate only over those items that are NOT the type "foo", namely 3 iterations instead of 5. I know that filters can somehow be leveraged to do this, but I am not sure how. I tried the following:
<div ng-repeat="item in items| !filter:{type:'foo'}">{{item.type}}</div>
but this doesn't work. In fact, even doing the following to limit to just 2 objects(those with item.type==="foo"), it doesn't work and does 5 iterations:
<div ng-repeat="item in items| filter:{type:'foo'}">{{item.type}}</div>
In essence, I want to do something similar to:
<div ng-repeat="item in items" ng-if="item.type !=='foo'>{{item.type}}</div>
However, I know that one doesn't work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…