我的问题 - 有一个网页,是对所有人开放。如果非注册用户进来,节省了提交表单有一个登录模式,询问登录。
My problem - there is a web page which is accessible to all. If unregistered user comes in and saves the form on submit there is a login modal which asks for login.
如果是新用户,他就会registrate和preSS再次提交。如果用户是不是新的,他将登录名和preSS再次提交。
If user is new he will registrate and press submit once again. If user is not new he will login and press submit once again.
如果注册的用户访问页面的表单名称正在验证与异步验证:
If registered user visits the page form name is being validated with async validator:
app.compileProvider.directive('nameAvailable', ['$q', '$http', 'service', function ($q, $http, service) {
return {
restrict: 'AE',
require: 'ngModel',
link: function ($scope, elem, attrs, ngModel) {
ngModel.$asyncValidators.queryName = function (queryName) {
--logic
}
}
}
}]);
如果注册的用户有这种形式保存在相同的名称,然后,如果他来填充它会失败,然后登录。
And if registered user has this form saved with the same name then it will fail if he fills it and then log in.
问题是 - 我怎么可以强制验证该字段用户登录后在
Question is - how can I force validation on that field after user logs in?
有一件事,我发现是使用ngModelController和呼叫的validate(),但如果要访问它在我的控制器?
One thing which I found is to use ngModelController and call validate(), but where to access it in my controller?
感谢您!
我创建了 plunker 样本如何来验证角方式异步数据。
I have created the plunker with sample how to validate async data in angular way.
下面更新 plunker 与验证按钮。