how to trigger angular parsers without inputing anything in the field

后端 未结 2 1061
借酒劲吻你
借酒劲吻你 2021-01-05 20:07

As the subject states, how do I trigger the actions to take place inside a

modelController.$parsers(...) 

without user input... the only wa

相关标签:
2条回答
  • 2021-01-05 20:19

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

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

    It`s so simple, and it seems to be the most correct solution.

    0 讨论(0)
  • 2021-01-05 20:36

    This question is actual for me also... Because i am resolving this issue with:

    var triggerParsers = function() {
        var val = ngModel.$viewValue; 
        ngModel.$setViewValue(null);
        ngModel.$setViewValue(val);
    };
    
    0 讨论(0)
提交回复
热议问题