In fact, I hope someone can help me with a problem that I had a couple of times recently.
Let's say I have 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 would like to display a table in a view that only displays fields in $scope.fields . It would be very simple if the table were flat, and I know that I can smooth it out using JavaScript, but there must be a way to do this by converting the dot notation to a path.
I added JSFiddle to demonstrate the problem I am facing:
JSFiddle : http://jsfiddle.net/7dyqw4ve/1/
I also tried to do something as suggested below, but the problem is its terrible practice of using functions in a view: Converting a JavaScript string in dotted notation to an object reference
If anyone has any ideas, I would really appreciate it.
source share