Created
February 2, 2015 17:51
-
-
Save ceccode/3d564d0500705e1969a6 to your computer and use it in GitHub Desktop.
Ionic framework confirm 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
| /** | |
| * Ionic framework confirm directive | |
| * thanks to: https://gist.github.com/asafge | |
| * | |
| * USAGE: pb-ion-sure-title="Confirm" pb-ion-sure-message="Are you sure" pb-ion-sure-click="funtion()" | |
| */ | |
| .directive('pbIonSureClick', ['$ionicPopup','$timeout', function($ionicPopup, $timeout) { | |
| return { | |
| restrict: 'A', | |
| link: function(scope, element, attrs) { | |
| element.bind('click', function() { | |
| var title = attrs.pbIonSureTitle || 'Confirm'; | |
| var template = attrs.pbIonSureMessage || 'Are you sure?'; | |
| var confirmPopup = $ionicPopup.confirm({ | |
| title: title, | |
| template: template | |
| }); | |
| confirmPopup.then(function(res) { | |
| if(res) { | |
| $timeout(function(){ | |
| scope.$apply(attrs.pbIonSureClick); | |
| }); | |
| } else { | |
| //console.log('Not sure'); | |
| } | |
| }); | |
| }); | |
| } | |
| } | |
| }]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment