0

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

1
  • 1
    But the children value inside the JSON is not the string "[]", it is an array []. Are you sure you didn't want mytree.currentNode.children.length == 0? Commented Dec 17, 2013 at 7:19

1 Answer 1

4

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

mytree.currentNode.children.length == 0
1
  • but one issue i notice is , if "children": "" the length will give 0 Commented Dec 17, 2013 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.