我想获得team_id和团队名称,但ng-change在这里不起作用。建议我更好地解决这个问题。
<th style="width:20%">
<select
style="height: 40px;
font-size: 12px;
width: 100%;
border-radius: 3px;
border: 1px solid #dfe3e9;
background: url(../image/select-icon.png) 100% no-repeat !important;
padding-left: 8px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding-right: 23px;"
ng-model="team_selected"
name="team_selected"
required=""
ng-change="selected_team(team_selected)">
<option value="" disabled="" selected="selected">Select Team</option>
<option
value="{{teams.team_id}}"
ng-repeat="teams in teamavailable track by teams.team_id">
{{teams.team_name}}
</option>
</select>
</th>
答案 0 :(得分:0)
尝试使用如下所示的ng-options代码,然后检查你的ng-change是否有效。
<select ng-model="team_selected" name="team_selected" required ng-change="selected_team(team_selected)" ng-options="team.team_id as team.team_name for team in teamavailable track by team.team_id" >
<option value="" disabled="" selected="selected">Select Team </option>
</select>
答案 1 :(得分:0)
您可以使用ng-options
并将团队对象用作选项值,这样您就可以将整个对象或所需属性传递给函数。
这是plunker example ...
<select ng-model="selected_team"
ng-change="selectTeam(selected_team.id, selected_team.name)"
ng-options="team.name for team in teams">
<option value="" disabled="" selected="selected">Select Team </option>
</select>