我试图弄清楚为什么Select下拉列表中的所有值都是不可见的。这是json的样子:
[{"team_id":"1","team":"Golden State Warriors","sport":"NBA"},{"team_id":"2","team":"Los Angeles Lakers","sport":"NBA"},{"team_id":"3","team":"Los Angeles Clippers","sport":"NBA"}]
以下是我的控制器的样子:
app.controller('getAllTeamsCtrl', function ($scope, $http)
{
$http({
method: 'GET',
url: 'getAllTeams.php'
}).then(function getTeamsSuccessful(response) {
$scope.listOfTeams = response.data;
$scope.selectedTeam = null;
console.log($scope.listOfTeams);
}, function getTeamsError(response) {
$scope.listOfTeams = response.statusText;
}); // End of HTTP GET
}); // End AngularJS
这就是我的HTML的样子:
<body ng-controller="getAllTeamsCtrl">
<form class="form-horizontal">
<div class="form-group">
<div class="col-md-4">
<select class="form-control"
ng-model="selectedTeam"
ng-options="item.team as item.team_name for item in listOfTeams">
</select>
<pre>selectedTeam : {{ selectedTeam | json }}</pre>
<div class="buttons">
<button class="btn btn-primary btn-block" type="submit">Save
</button>
</div>
</div>
</div>
</form>
<li ng-repeat="team in listOfTeams"> {{ team.team }} </li>
</body>
当我运行它时,我可以单击并关闭下拉列表,当我单击一个值时,我可以看到标签中的团队名称,但列表中的所有值都是不可见的。这与Twitter Bootstrap有关吗?
答案 0 :(得分:1)
您将值设置为team_name
且不存在,可能应更改为item.team_id