我正在尝试显示联盟中球队名称的列表,然后选择一个。选中后,应将league.teams[index]
的索引放入homeTeam.teamId
。这是HTML:
<select
ng-model="homeTeam.teamId"
ng-options="team.name for team in league.teams">
</select>
这里的范围:
$scope.league = {
teams: [
{ name: "Team#1" },
{ name: "Team#2" }
]
};
但它将整个对象添加到homeTeam.teamId
中,如下所示:
homeTeam: {
"teamId": { "name":"Team#1" }
}
如何才能输入索引,即:
homeTeam: {
"teamId": 0
}