尝试使用bootstrapcss
使用Angular-ui-validate来处理我的表单这是HTML
<div class='container' ng-controller='RegisterController as ctrl'>
<form class="form-register" ng-submit="ctrl.register()">
<h2 class=form-user-details">General Information</h2>
<div class="form-group">
<label for="inputEmail1">Email address</label> <input type="email"
class="form-control" ng-model='inputEmail' id="inputEmail1"
placeholder="Email" required autofocus> <span
style='font-size: 10px; color: red'>Note: Your email will
serve as your username!</span>
</div>
<div class="form-group" ng-class="{'has-error': !form.confirm_password.$error.validator}">
<label for="inputPassword">Password</label> <input name='password'
type="password" id='inputPassword' ng-model='password'
class="form-control" placeholder="Enter Password" ng-minlength="6" ng-maxlength="30" required>
<input type="password" class="form-control" name='confirm_password'
placeholder="Re-enter Password" ui-validate="'$value==password'"
ui-validate-watch="'password'">
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Create
Account</button>
</form>
</div>
指向angular-ui-validate https://github.com/angular-ui/ui-validate/blob/master/dist/validate.min.js
的链接链接到示例我看到: password-check directive in angularjs 第三个例子
看起来很简单但是!form.confirm_password。$ error.validator始终为真,无例外
答案 0 :(得分:0)
实际上发生的事情很少......首先我很愚蠢,忘了把ui-validate放在我的模型依赖中......
然后我需要在confirm_password字段中添加ng-model ...
最后我需要在表单中添加名称表单。
然后它起作用了......