How to run angular partners without typing anything in a field

As the subject states, how can I initiate actions within

modelController.$parsers(...) 

without user input ... the only way I can think of is to wrap them inside a function and call it, but is there a better way to call

**//pseudo
$(modelController).trigger('just got dirty');**

the reason I will need it is to force the input field to check itself when the page is submitted.

+5
source share
2 answers

I found a way to solve this - just call the parsers using the model value:

angular.forEach(ngModel.$parsers, function (parser) {
    parser(ngModel.$viewValue);
});

It is that simple, and it seems to be the right decision.

+9
source

This question is also relevant for me ... Because I solve this problem with:

var triggerParsers = function() {
    var val = ngModel.$viewValue; 
    ngModel.$setViewValue(null);
    ngModel.$setViewValue(val);
};
+1
source

All Articles