Reputation: 365
what i am trying to achieve is to show and element only if an children's value within a JSON object is equal to an string like '[]'.
I am having Json object mytree.currentNode value as
{
"Name": "Three Numbers",
"ParentId": "3",
"children": [],
"selected": "selected"
}
i show the information and i do something like:
<span ng-show="mytree.currentNode.children == '[]'">Selected Item: {{mytree.currentNode.Name}}</span>
But it is not checking the 'children' value is equal to "[ ]"
Thanks in advance
Upvotes: 0
Views: 1635
Reputation: 9156
"children": []
is not string '[]'
its an array , so check an empty array like
mytree.currentNode.children.length == 0
Upvotes: 4