Skip to content

Instantly share code, notes, and snippets.

@mahizsas
Last active August 29, 2015 14:16
Show Gist options
  • Save mahizsas/df748f6725d8bc5a838f to your computer and use it in GitHub Desktop.
Save mahizsas/df748f6725d8bc5a838f to your computer and use it in GitHub Desktop.
angular.module('autosaveExample', [])
.directive("Autosaved", ["$timeout", function($timeout) {
"use strict";
return {
link: function(scope, element, attrs) {
var autosave = function() {
$timeout(function() {
var form = scope[element.attr("name")];
if (form.$dirty) {
element.submit();
form.$setPristine();
}
autosave();
}, 300);
};
}
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment