AngularJS:使用ng-value时,value = 0?

齐夫

我遇到一个奇怪的错误。当我使用ng-value时,页面会为某些选项呈现“ value = 0”。控制台不显示错误。

这是代码:

<option ng-repeat="x in makes" ng-value="{{x.make_id}}">{{x.make}}</option>

结果如下:

<option ng-repeat="x in makes" ng-value="acura" class="ng-binding ng-scope">ACURA</option>
<!-- end ngRepeat: x in makes -->
<option ng-repeat="x in makes" ng-value="alfa-romeo" class="ng-binding ng-scope" value="0">ALFA ROMEO</option>
<!-- end ngRepeat: x in makes -->
<option ng-repeat="x in makes" ng-value="alpina" class="ng-binding ng-scope">ALPINA</option>
<!-- end ngRepeat: x in makes -->
<option ng-repeat="x in makes" ng-value="armstrong-siddeley" class="ng-binding ng-scope" value="0">ARMSTRONG SIDDELEY</option>
反应式

不要绑定表达式。ngValue使用$eval数据绑定,这意味着您应该删除{{ }}

<option ng-repeat="x in makes" ng-value="x.make_id">{{x.make}}</option>

编辑:这在AngularJS文档中没有很好地记录。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

#VALUE使用AVERAGEIFS时出错;范围从> 0开始的错误

使用if / then和.value时的#value

当我对大型数据集使用scipy.stats.kstest()时,p_value为0

AngularJS-当使用ng模型时,输入文本框中的Value属性会被忽略吗?

AngularJS-当使用ng模型时,将忽略选择/下拉列表上的Value属性

AngularJs:使用ng-value复制数据,但模型不会更新

将 value_counts 与 False/True 一起使用。当有任何假或真时如何获得假/真= 0

如何使div在input.value> 0时显示并在其为0时隐藏它?

getAttribute("value") 返回 0

当我尝试在这个项目中使用 input.value 取平均值时出现问题。无论我输入什么,Avarege 都会变为“0”

使用 has('prop', 'value') 和注入的 'value' 选择顶点时

ng-show Angularjs 在使用 CLI 时不起作用

使用ng-view(Angularjs)时隐藏某些HTML元素

在angularjs中使用ng-repeat时扩展$ index的范围

不使用jQuery时ng-include中的AngularJS错误

在angularJS中使用ng-style而不是style时出错

使用ng-model angularjs时不显示表单值

一起使用ng-model和`value`的AngularJS问题

AngularJS ng-repeat Post Value 使用 id 作为键没有进入正确的模式

使用Attribute =“ Value” jQuery时的替代方法

使用DATEVALUE函数时Excel #Value错误

使用 vapply 时缺少 FUN.VALUE

VBA #VALUE!" 使用函数时出错

#DIV/0!使用 AVERAGEIF 时

使用ng-include(AngularJS)时失去ng-model的范围

在Angularjs中使用ng-options时如何更新ng-model?

使用angularjs ng-options和ng-change时发送选项对象

角度:使用for(key,value)时对ng-options使用过滤器

AngularJs:使用 ng-model 也可以在显示中更改输入值。我也尝试过 ng-value 和 ng-bind