Code:
<input type="text" ng-modal="name" />
{{name}}
When I input something into the input, the following {{name}} will change immediately. Is it able to configure it only update the name after I input all characters and leave the input?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Update
As many have mentioned Angular now has built-in support for this using the
ng-model-optionsdirective. See more here.Old answer below:
There’s no built-in option for ng-model to change that behaviour, but you can write a custom directive doing it. @Gloopy wrote a directive like that for another question. You can look at the fiddle here.
The directive unregisters from the
inputandkeydownevents which trigger the update after each keystroke.Update:
Updated fiddle to use latest stable AngularJS (1.2.16 as of writing), instead of directly referencing the master version at github.
Also added an explicit priority so that the directive is run after
ng-modelto ensure event listeners are changed correctly.