我在使用ng-repeat
的angularjs中循环一个简单的json时遇到了问题。 json就是这个:
$scope.lines = {
data: [
{ "properties": {
"name": "My test",
"test:testOne": "This is test one" }
}
]
};
问题是:test:testOne
。我需要解析那个属性,但我不知道它是怎么做的,因为它有结肠。我在这里做了一个jsfiddle:http://jsfiddle.net/7MhLd/1250/其中我尝试了一些方法,但没有成功
答案 0 :(得分:2)
您可以使用[]
bracket notation,就像这样
<div ng-controller="MyCtrl">
<div ng-repeat="line in lines.data">
{{ line.properties['test:testOne'] }}
{{ line.properties.name }}
</div>
</div>