AngularJS: Debounce. Fire changes to apply on click -


there input debounce, 'clear' btn (to clear input) , 'use' btn (to use input value). :

<input ng-model="*"  ng-model-options="{ debounce: 1000 }" /> 

for proper 'clear' btn work $rollbackviewvalue() used (here)

<button ng-click='formname.$rollbackviewvalue();vm.clear()' /> 

but approach can used 'use' btn? how fire changes apply on click (before debounce interval ended)?

for 'use btn' use $commitviewvalue()

<button ng-click="userform.username.$commitviewvalue(); setvalue()">setvalue</button> 

just example

<form name="userform">     <label>name:         <input type="text" name="username"             ng-model="user.name"             ng-model-options="{ debounce: 1000 }" />     </label>     <button ng-click="userform.username.$commitviewvalue(); setvalue()">setvalue</button>      <button ng-click="userform.username.$rollbackviewvalue(); user.name=''">clear</button>     <br /> </form> 

demo http://plnkr.co/edit/ewansccfa72sdnk3regy?p=preview


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -