如何在Angularjs中为ng-repeat设置ng-model表单数据

时间:2015-04-18 16:36:23

标签: javascript angularjs

我想在Angularjs和使用中设置ng-model动态。

HTML

<div ng-repeat="option in optionListByCategoryId">
 <div class="form-group has-feedback" ng-if="option.type == 'number'">
  <label class="control-label col-sm-2 " for="active">{{option.name}}&nbsp;value = {{formData.optionList[{{option.id}}]}}</label>
  <div class="col-sm-10">
    <input  type="text" id="{{option.id}}" name="{{option.id}}" ng-model="formData.optionList[{{option.id}}]"  />
  </div>
</div>

在html中,我设置了ng-model formData,并使用ng-model optionListByCategoryId获取id optionList。

的Javascript

$scope.formData = {"optionList":{"1eb79b0b8b125270e1fd7ad50c0017e8":3,"1eb79b0b8b125270e1fd7ad50c000eb1":""}}

$scpe.optionListByCategoryId =[{"name":"DISKPLAY","description":"Inch", "active":true, "type":"number","step":1,"max":14,"min":3,"id":"1eb79b0b8b125270e1fd7ad50c0017e8"]

AngularJS中是否有错误。

Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 22 of the expression

请帮帮我。

0 个答案:

没有答案