In my angular app, I want to automatically save changes made by the user.
My strategy is that when the user stops to change, I want to do 20 seconds to AutoShare, if he is actively editing, then I want the timer to be the last Reset yourself to key stroke when it is allowed to run full 20 second course and trigger autosave.
How can I reset the clock regularly and any function can be triggered?
$ In the timeout angle, you can tell it from this function, through each ng-change Input is linked to the box. Cancel the promise and it has hit the ng-change every time.
HTML:
& lt; Body ng-controller = "MainCtrl" & gt; & Lt; Input type = text ng-model = "theValue" ng-change = "queetosave ()" /> & Lt; / Body & gt;
Script:
var app = angular. Module ('plunker', []); App.controller ('MainCtrl', function ($ range, $ timeout) {$ scope.theValue = 'World'; var Autosive promo; $ scope.QueueAutoSave = function () {$ timeout.cancel (Auto-Svepromoz); Autosave promo = $ timeout (function () {alert ("saved!");}, 20000);}});
Examples of working:
No comments:
Post a Comment