并非所有属性都绑定到ng-model

时间:2014-07-30 21:36:17

标签: javascript forms angularjs

我在我正在构建的应用中有一个表单,允许用户提交他们的姓名和电子邮件。此表单在两个选项卡上重复(在同一页面上)。这是基本形式:

<form class="user-submit-form" ng-submit="userSubmit(user)" ng-hide="userSubmitted">
  <h4><strong>FOR THE CHANCE TO HAVE YOUR STORY DRAWN, TELL US YOUR NAME AND CONTACT METHOD.</strong></h4>
  <span>Entries limited to one caption per cartoon per person.</span>
  <br>
  <input type="text" title="Name required" ng-model="user.name" size="32" placeholder="Name" required>
  <input type="email" title="Email required" ng-model="user.email" size="32" placeholder="E-mail Address" required>
  <br>
  <input type="checkbox" title="Must agree to Terms & Conditions" class="terms" 
         required><span>I have read and accept the Terms & Conditions</span>
  <br>
  <input class="user-submit-stories user-submit" type="image" src="images/submit_name.png">
</form>

当我更改user.name属性时,两个表单都会更新该值。但是,当我更新user.email属性时,不会更新其他表单的值。我还注意到,当我尝试在相关控制器中明确定义模型的属性时,不会在user.email的表单中进行更改

什么可能导致一个属性被正确绑定而另一个属性没有?

0 个答案:

没有答案