In my directive I am calling a function that's returning me the content of a JSON file, the content looks like this:
{
"UpdatedBy" : "Naguib",
"UpdatedOn" : "29/09/2016",
"UpdatedFrom": "data.doc",
"100":
[
{
"title":"Class View",
"overview":"TBC",
"menuItem":"TBC",
"UpdatedBy" : "Naguib",
"UpdatedOn" : "29/09/2016"
}
],
"101":
[
{
"title":"Time Table",
"overview":"TBC",
"menuItem":"TBC",
"UpdatedBy" : "Naguib",
"UpdatedOn" : "29/09/2016"
}
]
}
The function is working fine and returning me a JSON array in $scope.helptext
So when I call helptext
from HTML and pass the index of the first dimention it returns an array with the data but I can't get any data in the nested array:
<pre>
ONE
{{helptext[101]}}
TWO
{{helptext[101].menuItem}}
THREE
{{helptext[101][menuItem]}}
FOUR
{{helptext[101]['menuItem']}}
</pre>
The html that is generated is exactly how it looks:
<pre class="ng-binding">
ONE
[{"title":"Time Table","overview":"TBC","menuItem":"TBC","UpdatedBy":"Naguib","UpdatedOn":"29/09/2016"}]
TWO
THREE
FOUR
</pre>
Any help is appreciated!
helptext[100]
andhelptext[101]
are arrays. Arrays don't have amenuItem
property. The objects contained in these arrays do. This has nothing to do with Angular, only with how you structure your data and how to access objects/arrays. – Felix Kling 23 hours ago