【发布时间】:2014-01-06 10:53:32
【问题描述】:
我有一个类似的 nodeJSON 字符串
{
"Name": "Addition",
"Id": "3",
"ParentId": "1",
"children": [
{
"Name": "Two Numbers",
"Id": "5",
"ParentId": "3",
"children": []
},
{
"Name": "Three Numbers",
"Id": "6",
"ParentId": "3",
"children": []
}
]
}
我将 parentId 设为 3,然后我想将键值名称显示为“Addition”,该名称应与其 Id 匹配。
{
"Name": "Addition",
"Id": "3",
"ParentId": "1",
"children": [....]
}
myApp.controller('leafController', function($scope){
$scope.getname = function(parentid,nodeJSON )
{
//parentid is 3 here
$scope.Id = parentid;
$scope.data = nodeJSON ;
// i want to get name according to id
// Name : Addition (if Id is 3)
};
});
我被打动了。
请帮帮我,
提前致谢
【问题讨论】:
标签: javascript json node.js angularjs treeview