1

Here is my angularjs code for the password field :

<input type="password" class="form-control" name="password" ng-model="signup.registerPassword"  ng-minlength="8" >
<small class="errorMessage" data-ng-show="signupForm.registerPassword.$dirty && signupForm.registerPassword.$error.minlength"> Minimum 8 characters.</small>
<small class="errorMessage" data-ng-show="signupForm.registerPassword.$dirty && signupForm.registerPassword.$error.required"> Enter password again.</small>

when I type the password below 8 character it is not showing any error.

what is the mistake I am doing and how can I fix it ?

4

1 回答 1

1

registerPasswordng-model价值。signupForm将通过名称属性将其字段放在其中。当您给name="password"您的字段中包含password字段而不是表单时,然后在内部角度将password字段放置在 signupForm范围变量内。

更改signupForm.registerPasswordsignupForm.password

标记

<small class="errorMessage" data-ng-show="signupForm.password.$dirty && signupForm.password.$error.minlength"> Minimum 8 characters.</small>
<small class="errorMessage" data-ng-show="signupForm.password.$dirty && signupForm.password.$error.required"> Enter password again.</small>
于 2015-08-29T08:43:22.727 回答