0
私は表示しようとしているオブジェクトの配列を持っています。問題は、プロパティ名で呼び出すだけでデータにアクセスできることです。オブジェクトのキーを使用して反復処理を行いたいと思います。オブジェクトの配列に対するng-repeat(ng-startを使用)
オブジェクトには2つのプロパティがあり、各プロパティは開始時刻と終了時刻を表します。それらは各セルに表示されます。私は動的にオブジェクトにアクセスする方法を、ここでは
<table class="table table-striped">
<tr>
<th></th>
<th ng-repeat="department in departments" style="vertical-align:top" colspan="2">{{department}}</th>
</tr>
<tr ng-repeat="time in times">
<td>{{weekdays[$index]}}</td>
<td ng-repeat-start="dept in time">{{times[$index].service.start}}</td>
<td ng-repeat-end>{{times[$index].service.end}}</td>
</tr>
</table>
:
私のテーブルは、このように構成されていますか?
マイコントローラ:
.controller("businessHours", function($scope) {
$scope.weekdays = ["Sunday", "Monday", "Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
$scope.departments = ["sales", "service","accounting","bodyshop","other","parts"];
$scope.times = [];
$.each($scope.weekdays, function(index, value) {
var dayTimes = {};
$.each($scope.departments, function(index2, value){
console.log(index)
dayTimes[value] = {start: '5', end: '6'};
});
$scope.times.push(dayTimes);
});
})
私は正しくこのついて行くか、自分のデータ構造を配置する良い方法はありますかな?
本当にありがとうございました。レッスンでは、より多くのドキュメントを参照することを学びました。 – o6t9o