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>
Comments
Post a Comment