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.

1 Like

Try this,

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

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

1 Like

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

1 Like

I found this example in codepen: