Created
December 10, 2015 05:31
-
-
Save anjum121/5da1f9ad8b9e5e5002ba 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
/** | |
* A generic confirmation for risky actions. | |
* Usage: Add attributes: ng-really-message="Are you sure"? ng-really-click="takeAction()" function | |
*/ | |
(function () { | |
'use strict'; | |
angular | |
.module('c2k') | |
.directive('ngReallyClick', [ngReallyClickFunction]); | |
function ngReallyClickFunction() { | |
return { | |
restrict: 'A', | |
link: linkFn | |
}; | |
function linkFn(scope, element, attrs) { | |
element.bind('click', function(){ | |
var message = attrs.ngReallyMessage; | |
if(message && confirm(message)){ | |
scope.$apply(attrs.ngReallyClick) | |
} | |
}) | |
} | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment