How to open an ionic modal at a certain state


Is there a way to open an ionic Modal at a certain state?

I found in the ui-router docs an example using the bootstrap $modal service but I have no idea how to apply the $ionicModal service instead.


Try this,

$ionicModal.fromTemplateUrl('modal.html', {	
    scope: $scope,
    animation: 'slide-in-up'
.then(function(modal) {
    $scope.modal = modal;

This will immediately open a modal with template modal.html. Put this where the state’s controller is.


Just a minor improvement, move the $ into the .then() callback.


I found this example in codepen: