Created
November 13, 2015 19:49
-
-
Save edbentinck/31f5aa2640630a127a7f to your computer and use it in GitHub Desktop.
Revisions
-
melekes renamed this gist
Aug 18, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
melekes created this gist
Aug 18, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ angular.module('saveBeforeExitExample', []) .directive("saveBeforeExit", ["notificationService", function(notificationService) { "use strict"; return { link: function(scope, element, attrs) { window.onbeforeunload = function(){ if (element.hasClass("ng-dirty")) { element.submit(); } }; scope.$on("$locationChangeStart", function(event, next, current) { if (element.hasClass("ng-dirty")) { element.submit(); } }); } }; }]);