1
我有以下代碼:如何設置NG-模型動態
<div class="form-group" ng-repeat="(key, day) in {'monday':'Monday','tuesday':'Tuesday','wednesday':'Wednesday','thursday':'Thursday','friday':'Friday','saturday':'Saturday','sunday':'Sunday'}">
<label for="{{key}}" class="col-sm-3 control-label">{{day | translate}}</label>
<div class="col-sm-4">
<input type="number" class="form-control" ng-model="wd.{{key}}" id="{{key}}" name="{{key}}" min="1" placeholder="{{'Enter the price' | translate}}" required />
</div>
</div>
請注意,我對input
這是試圖以動態wd.{{key}}
設置模型的ng-model
。
當我運行這段代碼時,它說在.
之後有一個無效的屬性名稱。
我怎樣才能得到相同的效果?我不喜歡每週的每一天都有HTML代碼。