我试图在json对象中显示来自子数据和父数据的信息。以下是我的数据:
$scope.electionDetails = {
id : 1,
election_type: "CityCouncil",
election_name: "City A City Council Elections
candidates : [{
id: 1,
election_id: 1,
position_id: 1,
first_name: "John",
last_name: "Doe"
},
{
id:2,
election_id:1,
position_id:1,
first_name: "Jane",
last_name: "Doe"
},
{
id:3,
election_id:1,
position_id:2,
first_name: "Mike",
last_name: "Doe"
},
{
id:4,
election_id:1,
position_id:2,
first_name: "Mary",
last_name: "Doe"
}],
positions : [{
id:1,
election_id: 1,
position: "Seat 1"
},
{
id:2,
election_id:1,
position: "Seat 2"
}]
}
我想显示这些数据分组,使用角度如下:
城市A市议会选举
座位1
座位2
答案 0 :(得分:1)
你走了。 HTML结构可能不完全符合您的要求,因此您可以更改您使用的标记,但这是使用ng-if
和ng-repeat
创建给定席位候选列表的基本概念。 / p>