Skip to content

Instantly share code, notes, and snippets.

@ceccode
Created February 2, 2015 17:51
Show Gist options
  • Select an option

  • Save ceccode/3d564d0500705e1969a6 to your computer and use it in GitHub Desktop.

Select an option

Save ceccode/3d564d0500705e1969a6 to your computer and use it in GitHub Desktop.
Ionic framework confirm directive
/**
* 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