If you do not want to use ng-blur or lost focus, you can use the same ng-change with ng-model-options As of Angular 1.3, you could use Angular ng-model-options directive
When I want to call a function when typing is completed I use ng-keyup . Using ng-keyup your function will be call every time user press a key. I know your asking when user finish typing , but let me explain why I prefer using ng-keyup and not ng-blur If I have to call a validation function, ng-blur won't help, because you will have to focus out to launch the function. Using ng-keydown , function will be launch. so if user finished typing it will be launch also
3条答案
按热度按时间3wabscal1#
You should use
ng-blur
insteadA blur event fires when an element has lost focus.
If you do not want to use ng-blur or lost focus, you can use the same ng-change with
ng-model-options
As of Angular 1.3, you could use Angular ng-model-options directive
1l5u6lss2#
When I want to call a function when typing is completed I use
ng-keyup
.Using
ng-keyup
your function will be call every time user press a key.I know your asking when user finish typing , but let me explain why I prefer using
ng-keyup
and notng-blur
If I have to call a validation function,
ng-blur
won't help, because you will have to focus out to launch the function. Usingng-keydown
, function will be launch. so if user finished typing it will be launch alsoacruukt93#
我用这个函数在输入新值后调用。