$scope persons = [{"id":123, "name": "james",
"score": [{
"mark": 60,
"grade": D
}]
}]
我有2 ng-repeat。
<div ng-repeat="person in persons">
{{person.name}}
<span ng-repeat="scoreObj in person.score">
<p ng-click="something(person.id)"></p> <!-- won't work -->
{{person.id}} // work
</span>
</div>
我试图在person元素中获取person.id,它没有工作,任何想法?
答案 0 :(得分:0)
它有效,你的json应该是,
<div id="div1">
<button type="button">Button 1</button>
<button type="button">Button 2</button>
<button type="button">Button 3</button>
<button type="button">Button 4</button>
</div>
<强>样本强>
$scope.persons = [{
"id": 123,
"name": "james",
"score": [{
"mark": 60,
"grade": 'D'
}]
}]
var testApp= angular.module('test',[])
angular.module('test').controller('testCtrl', function($scope) {
$scope.persons = [{
"id": 123,
"name": "james",
"score": [{
"mark": 60,
"grade": 'D'
}]
}]
})