【问题标题】:Does a ng-model work on ng-repeated fields?ng-model 是否适用于 ng-repeated 字段?
【发布时间】:2015-12-09 15:48:50
【问题描述】:

我正在使用 ng-repeat,我处于不同级别,例如:

`ul in output.content.innercontent` or `li in ul.content.innercontent`

我的输入如下所示:

 <input id="{{input.key}}" name="{{input.label}}" type="text" 
        value="{{input.value}}" placeholder="{{input.defaultValue}}" 
       value="{{input.label}}" 
       class="form-control input-md" uib-tooltip="{{input.tooltip}}" 
       ng-if="input.type == 'input'">

每当发生更改时,在其中任何一个上,然后是 onBlur 我想拨打电话。使用所有这些字段的 ng-model 和 ng-model-options="{updateOn:'blur'}" 是否可行?我在网上看到的绑定行为主要是某个地方的只读字段的输入。我应该使用 ng-blur 和 on("change") 类型的行为吗?

【问题讨论】:

  • 你在输入中有两个不同的 value="" 而你忘记了 ng-model

标签: javascript angularjs angular-ngmodel


【解决方案1】:

试试

 <input id="{{input.key}}" name="{{input.label}}" type="text" 
    ng-model="{{input.value}}"  <!-- this -->
   placeholder="{{input.defaultValue}}" 
   class="form-control input-md" uib-tooltip="{{input.tooltip}}" 
   ng-if="input.type == 'input'">

ng-model 应该这样做


 <input ng-model-options"{updateOn: 'blur'}"/>

==> 这仅在用户超出输入时更新模型


在模糊上调用函数:

 <input ng-blur="callThisFn()"/>

【讨论】:

  • 感谢您的编辑,但 ng-model-options"{updateOn: 'blur'}" 在哪里更新?
  • ng-model-options"{updateOn: 'blur'}" 仅当您超出输入范围时才更新您放在 ng-model 上的变量
猜你喜欢
  • 1970-01-01
  • 2016-11-05
  • 2023-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-20
  • 2019-07-04
相关资源
最近更新 更多