I'm trying to replicate the 2-way data-binding example on the AngularJS website.
Here's my code (in JQuery parlance for brevity):
$('#model-textbox').on('keyup', function(){
//get value of text box
var text_box_str = $(this).val();
//add it to the view
$('#view-div').html(text_box_str);
});
It works as expected, but there seems to be some kind of delay from the time the key is released, to when the text is displayed. That delay does not happen on the AngularJS website example.
I have tried a 'keydown' event variation (which takes care of the delay), but it looks like the textbox value is not updated before the .val()
call (so I'm always one key press behind).
How can I achieve quick view updates using keyup
, keydown
, or any other method?