Angular strength asynchronizers

My problem is there is a webpage accessible to all. If an unregistered user logs in and saves the form on sending, there is a login motive that requests a login.

If the user is new, he will register and submit again. If the user is not new, he will log in and send submit again.

If a registered user visits, the page form name is checked using an asynchronous 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 the registered user has this form saved with the same name, then it will not succeed if he fills it out and then logs in.

Question: how can I force a check in this field after a user logs in?

One thing I found is to use ngModelController and call validate (), but where can I access it in my controller?

Thanks!

+6
source share
1 answer

I created a plunker with an example of how to check asynchronous data on angular.

Here plunker is updated with the confirmation button.

+4
source

Source: https://habr.com/ru/post/987787/


All Articles