Last active
August 29, 2015 14:16
-
-
Save mahizsas/df748f6725d8bc5a838f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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