Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/479.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 以angularjs和ng repeat生成的形式使用插值范围字段名_Javascript_Angularjs_Angularjs Directive_Angularjs Ng Repeat - Fatal编程技术网

Javascript 以angularjs和ng repeat生成的形式使用插值范围字段名

Javascript 以angularjs和ng repeat生成的形式使用插值范围字段名,javascript,angularjs,angularjs-directive,angularjs-ng-repeat,Javascript,Angularjs,Angularjs Directive,Angularjs Ng Repeat,我需要使用ng repeat生成一个表单。范围变量的名称,我希望输入的结果被定位,我作为参数之一给出,所以它必须被插值 用于调整的Plunker位于。 下面是形式的定义 $scope.formFields = [ { id: "sample11", nextfree: 'rcv.UseNextFreeSampleId', ngmodel: 'rcv.SampleId', maxlen: 10, focus: false, u

我需要使用ng repeat生成一个表单。范围变量的名称,我希望输入的结果被定位,我作为参数之一给出,所以它必须被插值

用于调整的Plunker位于。

下面是形式的定义

$scope.formFields = [                       
 {
  id: "sample11",
  nextfree: 'rcv.UseNextFreeSampleId',
  ngmodel: 'rcv.SampleId',
  maxlen: 10,
  focus: false,
  useNextFree: true,
  useHint: true,
  text: {status: "status must be shown"}
}
];
其中我指定$scope.rcv.SampleId应包含结果

HTML看起来像:

<input class="input-small form-control" ng-required="!{{field.nextfree}}" type='text'    
    id='field.id' ng-model='{{field.ngmodel}}'
    ng-maxlength='field.maxlen'  ng-disabled='{{field.nextfree}}>
<span class="input-group-addon" ng-show='field.useNextFree'>
      <input type = "checkbox", ng-model='{{field.nextfree}}'  ng-value = "true" >
      <label>Use Option</label>
</span>
<span class="help-block small" ng-show='field.useHint'>{{field.text.status}}</span>

Angular不允许将插值用作ng模型

您可以通过稍微更改字段来实现所需的功能。
nextfree:'UseNextFreeSampleId',ngmodel:'SampleId'
,然后将其作为$scope.rvc:
ng model=“rcv[field.ngmodel]”的属性引用。