我想要實現的是兩個輸入字段,我想比較一下。如果相同,表格必須有效。否則,無效。這是代碼:
<form name="form" class="css-form" novalidate>
E-mail: <input type="email" placeholder="[email protected]"
ng-model="user.email" name="uEmail" required/>
<span class="error" ng-show="form.uEmail.$error.email">
Not valid email!</span>
Repeat e-mail: <input type="email" placeholder="[email protected]"
ng-model="repEmail" required/>
<span ng-if="user.email != repEmail">
E-mail address are not same!
</span>
</form>
問題是,儘管這些領域都不盡相同,這是真的:
form.$valid == true
因此,如何更改表格的有效性,以便它可以是假的如果輸入的字段不一樣(儘管它們是有效的電子郵件地址)
看到這個http://stackoverflow.com/questions/14012239/password-check-directive-in-angularjs 希望它能幫到你 – Alexei