问题描述
- AngularJS回显后验证并未生效?
-
代码部分:
var app=angular.module("app",[]);
app.controller("checkform",["$scope",function($scope){}]);
##验证两次密码是否一致
app.directive('pwCheck', [function () {
return {
require: 'ngModel',
link: function (scope, elem, attrs, ctrl) {
var firstPassword = '#' + attrs.pwCheck;
elem.add(firstPassword).on('keyup', function () {
scope.$apply(function () {
var v = elem.val()===$(firstPassword).val();
ctrl.$setValidity('pwmatch', v);
});
});
}
}
}]);$("input[name=userName]").val("$!{userInfo.userName}");页面加载完成后的赋值。
请问这种问题如何解决呢?
解决方案
http://www.cnblogs.com/rohelm/p/4033513.html
时间: 2024-10-26 05:43:27