我有business_hours的这个架构:
business_hours: {
sunday: {closed: {type:Boolean, trim: true},
timings: [{
open: {type:Number, default: '', trim: true},
close: {type:Number, default: '', trim: true}
}]},
monday: {closed: {type:Boolean, trim: true},
timings: [{
open: {type:Number, default: '', trim: true},
close: {type:Number, default: '', trim: true}
}]},
tuesday: {closed: {type:Boolean, trim: true},
timings: [{
open: {type:Number, default: '', trim: true},
close: {type:Number, default: '', trim: true}
}]},
wednesday: {closed: {type:Boolean, trim: true},
timings: [{
open: {type:Number, default: '', trim: true},
close: {type:Number, default: '', trim: true}
}]},
thursday: {closed: {type:Boolean, trim: true},
timings: [{
open: {type:Number, default: '', trim: true},
close: {type:Number, default: '', trim: true}
}]},
friday: {closed: {type:Boolean, trim: true},
timings: [{
open: {type:Number, default: '', trim: true},
close: {type:Number, default: '', trim: true}
}]},
saturday: {closed: {type:Boolean, trim: true},
timings: [{
open: {type:Number, default: '', trim: true},
close: {type:Number, default: '', trim: true}
}]}
},
我正在为上面的架构创建UI。所以我正在使用ng-repeat来达到这个目的。我在控制器中定义了一个数组周:
$scope.week = ['Sunday','Monday' ,'Tuesday' ,'Wednesday' ,'Thursday' ,'Friday', 'Saturday'];
HTML代码如下:
<div class="row-fluid span12">
<small>Timings</small>
</div>
<div ng-repeat="w in week">
<div class="row-fluid pushTop10px">
<div class="row-fluid span4">
<small>{{w}}</small>
</div>
<div class="row-fluid span8 " >
<div class="row-fluid span2" style="text-align:center; margin-top:4px;">
<small>Open</small>
</div>
<div class="row-fluid span2">
<select class="span12" ng-model="outlet.business_hours.timings.w.open.hour">
<option value="1"><label>00</label></option>
<option value="2"><label>01</label></option>
此代码继续。基本上有四件事:开放时间,开放时间,关闭时间,关闭时间。我只是在打印时,周工作正常。但是当我在模型中使用它时,它并不起作用。 我也试过以下代码:
outlet.business_hours.timings.{{w}}.open.hour
outlet.business_hours.timings.week[w].open.hour
outlet.business_hours.timings.week($index).open.hour
怎么做?
答案 0 :(得分:1)
你能试试吗
outlet.business_hours[w].timings[0].open(hour)
小时是范围内的财产
另外,星期天!=星期天;)
你能提供更多代码吗?
答案 1 :(得分:0)
以下是:
outlet.business_hours[w].timings[0].open.hour