我需要创建一种哈希表,我无法做到检索某些值。这是情况;获取将值传递给javascript的值
我有一个JSON有像这样的一些属性:
$scope.getItems = {
"data": [{
"label": "first-label",
"objects": [{
"name": "firstObj",
"attributes": [{
"attrname": "Item1",
"attrValue": "",
"attrType": "text"
}, {
"attrname": "Item2",
"attrValue": "",
"attrType": "text"
}]
}],
"properties": {
"film:property": "action"
}
},
{
"label": "second-label",
"objects": [{
"name": "firstObj",
"attributes": [{
"attrname": "Item1",
"attrValue": "",
"attrType": "text"
}, {
"attrname": "Item2",
"attrValue": "",
"attrType": "text"
}]
}],
"properties": {
"film:property": "action"
}
},
{
"label": "third-label",
"objects": [{
"name": "firstObj",
"attributes": [{
"attrname": "Item1",
"attrValue": "",
"attrType": "text"
}, {
"attrname": "Item2",
"attrValue": "",
"attrType": "text"
}]
}],
"properties": {
"film:property": "drama"
}
},
{
"label": "fourth-label",
"objects": [{
"name": "firstObj",
"attributes": [{
"attrname": "Item1",
"attrValue": "",
"attrType": "text"
}, {
"attrname": "Item2",
"attrValue": "",
"attrType": "text"
}]
}],
"properties": {
"film:property": "action"
}
},
{
"label": "fifth-label",
"objects": [{
"name": "firstObj",
"attributes": [{
"attrname": "Item1",
"attrValue": "",
"attrType": "text"
}, {
"attrname": "Item2",
"attrValue": "",
"attrType": "text"
}]
}],
"properties": {
"film:property": "comic"
}
}
]
};
那好吧,现在,我需要的是film:property
和label
。 正如你所看到的电影:财产“行动”,我们有一个以上的标签,exaclty:
- first-label
- second-label
- fourth-label
这样一个假设树视图可能是:
- action
- first-label
- second-label
- fourth-label
-drama
- third-label
-comic
-fifth-label
我在这里做了一个的jsfiddle: https://jsfiddle.net/vuqcopm7/58/其中有相同的JSON和像这样的列表:
<ul data-ng-repeat="object in uniqueNames">
<li ng-click="getLabelByProp(object)">
<a style="cursor:pointer">{{object}}</a>
</li>
</ul>
我需要的是当我点击在项目与property.For例如获得标签:
在行动点击我需要的地方显示,它并不重要,因为,
- first-label
- second-label
- fourth-label
等为他人。感谢帮助!
是!感谢的人似乎正是我期待的! –