Close Modal, dont' go back to index

Hi there,
first i wanted to thank you for all the effort on ionic. I’m really exited about this project.

I got an app with different routes.
An “index” route and then a “list” route.
In my list route i got a list of items to scroll.

When i click on an item, i’m opening a Modal() “window” via:

$scope.openModal = function(index) {

If i now close my Modal via:

$scope.closeModal = function() {

I’m getting redirected to my “index” route.
But i really need to stay on the “list” route, because otherwise the user loses the scrolling through the list of items and has to begin on top if again visiting the “list” route.

Is there a way to close a Modal() without getting redirected to the index route?

Best regards

1 Like

Hey @ageibert. I’m not sure why you’d be redirected in this case. Can you share what your markup looks like? Are you possibly using an anchor tag for these functions? Maybe try a button in that case.

Hey Max,
may code looks like this:


<a class="item item-thumbnail-left" href="#" ng-click="openModal($index)" ng-repeat="recipe in recipes">
  <img src="">

This is a list item an i want to open the modal if the item is clicked anywhere. I can’t use a button here…

The JS:

  Modal.fromTemplateUrl('templates/detail.html', function(modal) {
    $scope.modal = modal;
  }, {
    scope: $scope,
    animation: 'slide-in-up'
  $scope.openModal = function(index) {
    $scope.recipe = $[index];
  $scope.closeModal = function() {

The modal is then closed via the automatically provided close button.

Hmm. Did you try removing the href from the <a tag?

Hi Max,
i removed the “href” attribute, but it redirected me back to the index again.

Now i substituted the “a tag” with a “div” and everything works fine.

Except the small arrow on the right side “>”, which i automatically established if one uses an “a tag”, isn’t shown anymore, but this is not so important :slight_smile:

I thank you!