我正在使用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打开。
答案 0 :(得分:0)
tags
在select option
标记内无效。您可以通过在ng-change
框的select
上调用该函数来从控制器功能进行路线导航
<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
});
}