Seeking assistance with a recurring issue I've encountered lately.
Imagine having two objects in AngularJS:
$scope.fields = ['info.name', 'info.category', 'rate.health']
$scope.rows = [{
info: { name: "Apple", category: "Fruit"},
rate: { health: 100, ignored: true}
},{
info: { name: "Orange", category: "Fruit"},
rate: { health: 100, ignored: true}
},{
info: { name: "Snickers", category: "Sweet"},
rate: { health: 0, ignored: true}
}]
I aim to display a table on a view that only exhibits the fields listed in $scope.fields
. While flattening the table using JavaScript is an option, I'm curious if there's a method to achieve this by converting the dot notation into the path.
I have included a JSFiddle link to showcase the issue I am encountering:
JSFiddle: http://jsfiddle.net/7dyqw4ve/1/
I have also experimented with a suggested approach but utilizing functions in the view is not recommended: Convert JavaScript string in dot notation into an object reference
If you have any insights or solutions, your input would be highly valued. Thank you.