[英]Put ui-sref in select / option
我正在使用AngularJS,我想在選項中使用ui-sref。 我使用的這種方法不起作用
<div class="col-sm-1">
<select style="width: 117px;" ng-model="selectedTeam">
<option selected disabled>Teams</option>
<option ng-repeat="x in teams" value="{{x.team_id}}">
<a ui-sref="player-statistic.player-statistic-account({ teamId: x.team_id })">
{{x.team_name}}
</a>
</option>
</select>
</div>
<div class="col-sm-1" ng-show="selectedTeam">
<select style="width: 117px;">
<option selected disabled>Account</option>
<option ng-repeat="y in account" ng-if="y.team_id == selectedTeam">
{{y.first_name}} {{y.last_name}}
</option>
</select>
</div>
根據您選擇的選項,此鏈接將按ID打開。
tags
在select的option
標簽內不起作用。 您可以通過在select
框的ng-change
上調用該功能來從控制器功能進行路線導航
<select style="width: 117px;" ng-model="selectedTeam" ng-change="changeLocation(selectedTeam)">
<option selected disabled>Teams</option>
<option ng-repeat="x in teams" value="{{x.team_id}}">
{{x.team_name}}
</option>
</select>
碼
$scope.changeLocation = function(teamId) {
$state.go('player-statistic.player-statistic-account', {
teamId: teamId
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.