0
我有一个输入确认电子邮件的两倍,如何运行customed指令和正常NG-指令还
然而,当我用check-email
指令和required
验证不能正常工作了。
有什么建议吗?我不希望用户保持这一领域的空白
HTML
<input type="text"
id="confirm_email_booking"
name="confirm_email_booking"
class="form-control"
check-email
ng-model="payment_contact.confirm_email_booking"
/>
JS
app.directive('checkEmail', function() {
return {
require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
ctrl.$parsers.unshift(function(viewValue, $scope) {
var notMatch = (viewValue != scope.form.email_booking.$viewValue)
ctrl.$setValidity('notMatch', !notMatch)
return notMatch;
})
}
}
})
嘛,我看不到任何'required'这里.. – developer033
你为什么不只需添加校验功能'Ctrl键。$ validators'? – MMhunter