我有一个形式为角色变量的数据:
$scope.roles = [
{id: 1, text: 'a'},
{id: 2, text: 'b'},
{id: 3, text: 'c'},
{id: 4, text: 'd'},
{id: 5, text: 'e'},
{id: 6, text: 'f'}
];
我将所有角色提取到我的html中,如下所示:
<label ng-repeat="role in roles">
<input type="checkbox" name="sportId" ng-required="!sportId" data-checklist-model="player.sport_id" data-checklist-value="role.id" ng-click="myFunction(role.id)"> {{role.text}}
</label>
在每个复选框上,我想要调用此myFunction
:
$scope.myFunction = function(id){
$http.get('v1/sp/' + $scope.player.sport_id + '/pstn')
.success(function (data) {
$scope.pstn = data.data;
});
};
但是如果我选择id
数字3带来了属于id
数字3的响应和文本:c,它会调用一次,如果我选择1然后将响应对应于1。 / p>
我怎么能得到完整的响应,即如果我选择1带一个值而我选择2它同时带2的值如果我选择1,2,3显示所有三个响应不是最后选择id我选择的值因为现在它正在发生:
<div class="styled-select tab-content">
<select name="position" ng-options="position.position_id as position.name for position in positions" ng-model="player.position_id" required>
<option value="" selected="selected">-- Select --</option>
</select>
</div>
</div>
它应该在这里:
<section ng-init="tab = 1">
<ul class="nav nav-pills">
<li ng-class="{ active:tab ===1 }">
<a href ng-click="tab = 1">a</a>
</li>
<li ng-class="{ active:tab ===2 }">
<a href ng-click="tab = 2">b</a>
</li>
</ul>
<div class="panel" ng-show="tab === 1">
<span playerposition></span>
</div>
<div class="panel" ng-show="tab === 2">
<span playerposition></span>
</div>
</section>