I have a JSON object with different names for each property, like so:
var definitions = {
foo: {
bar: {abc: '123'},
baz: 'def'
},
qux: {
broom: 'mop',
earth: {
tree: 'leaf',
water: 'fish'
},
fig: {
qwerty: 'olive'
}
},
blix: {
worm: 'dirt',
building: 'street'
}
... more nested objects
};
Right now, I am displaying this data like so:
<div class="type" ng-repeat="(key,val) in definitions">
<h4 ng-model="collapsed" ng-click="collapsed=!collapsed">{{key}}</h4>
<div ng-show="collapsed">{{val}}</div>
</div>
And here's my controller:
App.controller('DefinitionsCtrl', function ($scope) {
$scope.definitions = definitions;
});
{{val}}
simply shows a condensed string of the property when its respective {{key}}
is clicked. I would like to properly parse the val
portion further, so for instance foo
's nested properties (bar
and baz
) would have their own divs respectively. However, I would like to do this for all the nested values. Doing this manually is not an option (it's a huge file).
Is this possible considering all the nested names are different? Would I have to create a custom filter, or is this something I should handle in the controller?