Created
July 20, 2015 21:52
-
-
Save nicon-dev/9be16613a08c2be7527a to your computer and use it in GitHub Desktop.
IONIC: Popups
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
// Alert popup | |
// Just Text and one OK button | |
var alertPopup = $ionicPopup.alert({ | |
title: 'Don\'t eat that!', | |
template: 'It might taste good' | |
}); | |
alertPopup.then(function(res) { | |
console.log('Thank you for not eating my delicious ice cream cone'); | |
}); |
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 confirm dialog | |
// with text, Ok and Cancel buttons | |
var confirmPopup = $ionicPopup.confirm({ | |
title: 'Consume Ice Cream', | |
template: 'Are you sure you want to eat this ice cream?' | |
}); | |
confirmPopup.then(function(res) { | |
if(res) { | |
console.log('You are sure'); | |
} else { | |
console.log('You are not sure'); | |
} | |
}); |
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
// An elaborate, custom popup | |
// Popup with Input, Cancel, Save | |
var myPopup = $ionicPopup.show({ | |
template: '<input type="password" ng-model="data.wifi">', | |
title: 'Enter Wi-Fi Password', | |
subTitle: 'Please use normal things', | |
scope: $scope, | |
buttons: [ | |
{ text: 'Cancel' }, | |
{ | |
text: '<b>Save</b>', | |
type: 'button-positive', | |
onTap: function(e) { | |
if (!$scope.data.wifi) { | |
//don't allow the user to close unless he enters wifi password | |
e.preventDefault(); | |
} else { | |
return $scope.data.wifi; | |
} | |
} | |
} | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment