質問

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

役に立ちましたか?

解決

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

mytree.currentNode.children.length == 0
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top