javascript - Getting an input's current value in a keypress event in angularjs -
i'm trying add dirty class input while user typing. i'v created directive binds keydown
event , checks value against last saved one.
elm.bind('keydown', function(event) { if (event.which === 13) scope.update(); else if ( scope.last_saved_value !== elm.val() ) elm.addclass('dirty-input'); });
to see problem, change value in input , press enter. works fine. now, add number , you'll see field not become dirty , event capturing previous value , not current. guess elm.val()
\ model.$viewvalue
being updated after event taken care of (to allow manipulation on value).
so how can capture current value on keydown
?
Comments
Post a Comment