[previous answer]
I had a problem with this problem today, and I solved it by starting and sorting the $parsers pipeline capture using closure.
const hijack = {trigger: false; model: null}; modelCtrl.$parsers.push( val => { if (hijack.trigger){ hijack.trigger = false; return hijack.model; } else {
Then, to reset the model, you need to start the pipeline by changing $viewValue to modelCtrl.$setViewValue('newViewValue') .
const $setModelValue = function(model){
Using $setViewValue() , you will call the $parsers . Then the function that I wrote in the first block of code will be executed using val = getViewValue(model) , after which it will try to analyze it for something that needs to be used for your $modelValue according to the logic there. But for now, the closing variable captures the parser and uses it to completely overwrite the current $ modelValue.
At this point, val not used in $parser , but it will still be the actual value displayed in the DOM, so choose a good one.
Let me know if this approach suits you.
[edit]
It seems like ngModel. $ commitViewValue should also start the $ parsers pipeline, I tried quickly, but could not get it to work.
source share