javascript - AngularJS: Filtering json objects instead of an array -
as filters provided angularjs work arrays not objects, i'm using filter function suggested in this solution.
now want extend it, because json info additionally has settings-object storing visibility info filtering (unfortunately can not modify json structure):
$scope.data = { "groups":{ "1": { "type": "foo", "name": "blah", "settings": { "visibility":[true] } }, "2": { "type": "bar", "settings": { "visibility":[false] } } } } therefore filter phone call more complex, of course of study not work filter @ moment:
<div ng-repeat="(key, value) in data.groups | objectbykeyvalfilter:'settings.visible[0]':true> {{key}} {{value.type}} </div> probably
objectbykeyvalfilter:'settings.visibility[0]' : true becomes wrongly that
myobject['settings.visibility[0]'] how can modify filter function in order accomplish filtering?
not working plunker: http://plnkr.co/edit/f202la?p=preview
what bit different approach : plnkr
<div ng-repeat="(key, value) in data.groups "> <span ng-show="value.settings.visible"> {{key}} {{value.type}} <span> </div> javascript json angularjs
No comments:
Post a Comment