【问题标题】:AngularJS model is not updating view when using input type as number使用输入类型作为数字时,AngularJS模型不更新视图
【发布时间】:2014-04-21 06:54:52
【问题描述】:

当我使用输入类型作为带有值属性的数字时,它没有在输入框中显示值。但是,当我将其更改为文本时,它可以正常工作。

<input value="30" ng-model="project.camp_duration" min="30" max="60" id="camp_duration" name="camp_duration" type="text" placeholder="Days" class="form-control input-md" required="" autocomplete="off">

<input value="30" ng-model="project.camp_duration" min="30" max="60" id="camp_duration" name="camp_duration" type="number" placeholder="Days" class="form-control input-md" required="" autocomplete="off">

上面,第一个用给定的值填充文本框。

我错过了什么还是这是一个错误。

【问题讨论】:

    标签: html angularjs validation


    【解决方案1】:

    类型为number 的输入必须是integer

    我认为你的 project.camp_duration 是一个字符串。

    【讨论】:

      猜你喜欢
      • 2016-02-05
      • 1970-01-01
      • 2015-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-13
      • 2013-12-02
      • 2012-12-31
      相关资源
      最近更新 更多