Might be missing some simple syntax, but I can't seem to get not equal filter to work:
I can do
filter: {property:{text:'yes'}}
,
but not
filter: {property:{text:'!yes'}}
,
which does work for non-nested objects.
HTML:
<ul>
<li ng-repeat="attr in attributes | filter: {property:{text:'!yes'}}">
{{attr.property.text}}
</li>
</ul>
JS:
$scope.attributes = [
{property: { text:'yes' }},
{property: { text:'no' }},
];
Plunkr link:
http://plnkr.co/edit/2mTcQijmfnqAM5vUtKsK?p=preview
You can get the same effect with ng-if
like this:
<ul>
<li ng-repeat="attr in attributes" ng-if="attr.property.text !== 'yes'">
{{attr.property.text}}
</li>
</ul>
Alternatively you could write a custom filter that contains the logic or flatten the original structure somehow. I don't think !
is supported in nested structures.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With