Skip to content

Instantly share code, notes, and snippets.

@icaroscherma
Last active March 31, 2017 11:33
Show Gist options
  • Save icaroscherma/01966aa5933ed7f2127d to your computer and use it in GitHub Desktop.
Save icaroscherma/01966aa5933ed7f2127d to your computer and use it in GitHub Desktop.
Ionic Sample: Confirm Popup with checkbox
// Using show()
$scope.garageToggle = function() {
$scope.data = { hasWorkEntry: true };
$ionicPopup.show({
title: 'Are you sure you want to open the garage?',
content: '<ion-checkbox ng-model="data.hasWorkEntry" ng-checked="data.hasWorkEntry">Mark as Work Entry?</ion-checkbox>',
scope: $scope,
buttons: [
{text: 'Cancel'},
{
text: '<b>OK</b>',
type: 'button-positive',
onTap: function(e) { return e; }
}
]
})
.then(function(res) {
if (res)
{
console.log('You asked to open it!');
if($scope.data.hasWorkEntry) {
console.log('and also to mark this as a work log (entry or leave)!');
}
}
});
};
// using Confirm()
// Ps.: In the Cordova Docs, the Confirm() doesn't have a scope param, but it works if you pass it
$scope.pedestrianToggle = function() {
$scope.data = { hasWorkEntry: true };
$ionicPopup.confirm({
title: 'Tem certeza que deseja abrir o Portão de Pedestres?',
content: '<ion-checkbox ng-model="data.hasWorkEntry" ng-checked="data.hasWorkEntry">Marcar como ponto?</ion-checkbox>',
scope: $scope
})
.then(function(res) {
if(res) {
console.log('You are sure');
if($scope.data.hasWorkEntry) {
console.log('ponto!');
}
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment