link: function(scope, elm, attrs, ctrl) {
ctrl.$parsers.unshift(function(viewValue) {
scope.pwdValidLength = (viewValue && viewValue.length >= 8 ? 'valid' : undefined);
scope.pwdHasLetter = (viewValue && /[A-z]/.test(viewValue)) ? 'valid' : undefined;
scope.pwdHasNumber = (viewValue && /\d/.test(viewValue)) ? 'valid' : undefined;
if(scope.pwdValidLength && scope.pwdHasLetter && scope.pwdHasNumber) {
ctrl.$setValidity('pwd', true);
return viewValue;
} else {
ctrl.$setValidity('pwd', false);
return undefined;
}
});
}
http://jsfiddle.net/adamdbradley/Qdk5M/
В вышеупомянутой скрипте, как происходит проверка пароля? Что делает $parser.unshift? и каково использование теста (viewValue).....? Я упомянул сайт AngularJs, но не мог понять ничего... Пожалуйста, направляйте меня шаг за шагом, как это подтверждается...
Я новичок в angularJS..