Question

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

Was it helpful?

Solution

"children": [] is not string '[]' its an array , so check an empty array like

mytree.currentNode.children.length == 0
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top