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.
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?
One thing which I found is to use ngModelController and call validate(), but where to access it in my controller?
Thank you!
I have created the plunker with sample how to validate async data in angular way.
Here updated plunker with validate button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With