Created
December 29, 2013 13:47
-
-
Save pengux/8170644 to your computer and use it in GitHub Desktop.
Angularjs confirm click directive
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 characters
| /*global window */ | |
| define(['angular', 'services'], function(angular, services) { | |
| 'use strict'; | |
| /* Directives */ | |
| angular.module('app.directives', []) | |
| .directive('ngConfirmClick', [ | |
| function(){ | |
| return { | |
| link: function ($scope, element, attr) { | |
| var msg = attr.title || "Are you sure?"; | |
| var clickAction = attr.ngConfirmClick; | |
| element.bind('click', function (event) { | |
| if (window.confirm(msg)) { | |
| $scope.$eval(clickAction); | |
| } | |
| }); | |
| } | |
| }; | |
| } | |
| ]); | |
| }); |
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 characters
| <a ng-confirm-click="delete('{{ object.id }}')" title="Do you really want to delete this object?">Delete</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment