1
我試圖在我的角度應用程序中實現一個選擇,以顯示有關表格中電視節目劇集的數據。ng選項在選擇中不起作用
在選擇中,用戶應該能夠選擇其中一個劇集。
我嘗試了ng-repeat
選項元素,它的工作。但是當我嘗試爲選擇設置ng-options
時,它們似乎不被識別。
任何想法,我在這裏錯了什麼?
這裏是我的html:
<div class="container-fluid full-height">
<div id="tabs_container" class="col-xs-12">
<div ng-app="seriesAnalyzer" ng-controller="configTableController">
<label>
Episode:
<select>
<option ng-repeat="episode in all_episodes | orderBy:['season_number','episode_number']">Season: {{episode.season_number}} Episode: {{episode.episode_number}}</option>
</select>
</label>
<!-- This is not working -->
<label>
Episode:
<select ng-options="episode.season_number for episode in all_episodes track by id">
<option value="">Please select an episode...</option>
</select>
</label>
<div ng-init="episode = episode_data">
<p>{{episode_data.episode_number}}</p>
<p>{{episode_data.season_number}}</p>
</div>
<table st-table="rowCollection" class="table table-striped">
<thead></thead>
<tbody>
<tr ng-repeat="scene in episode_data.configuration_matrix">
<td ng-repeat="values in scene track by $index" ng-style="set_color(values)" >{{values}}</td>
</tr>
</tbody>
</table>
</div>
<br>
</div>
</div>
而且我的控制器:
seriesAnalyzer.controller('configTableController', function ($scope, $http) {
var req_url = 'http://localhost:8080/api/episodes';
$http.get(req_url)
.success(function (data) {
$scope.all_episodes = data;
console.log($scope.all_episodes);
})
.error(function (data) {
console.log('Error: ' + data);
});
$scope.update_season_number = function(){
console.log(val);
};
$scope.update_episode_number = function(){
console.log("Input changed");
};
var get_episode_data = function()
{
var req_url = 'http://localhost:8080/api/episodes?season_id=' + $scope.season_number + '&episode_id=' + $scope.episode_number
$http.get(req_url)
.success(function (data) {
$scope.episode_data = data;
})
.error(function (data) {
console.log('Error: ' + data);
});
};
....
這適用於我,但我需要season_number和episode_number顯示爲「季節1插曲2」。我怎樣才能做到這一點? – Igle
@Igle' episode.season_number +''+ episode.episode_number for episode in all_episodes track by episode.id' – Akis
@Igle you can also'group by'' episode.season_number' – Akis