Angularjs - set view value is not updating display

haki picture haki · Apr 5, 2014 · Viewed 14k times · Source

I got an input directive that should allow users to undo.

Enter saves the value using some function, Esc Cancel edits from the last save.

For the Esc keypress event i'm using ngmodel.$setViewValue(scope.last_saved_value) but the input is not updating. I know from the docs that this function does not trigger $digest so i put it in an $apply but it is still not working.

JSBIN example

Answer

Ivan Koshelev picture Ivan Koshelev · Apr 7, 2014

Try calling ngmodel.$render(); after you do $setViewValue, it should help.