2
我想弄清楚爲什麼選擇下拉列表中的所有值都是不可見的。這裏是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有關嗎?
這是它。謝謝! –