Devesh M
Devesh M

Reputation: 1033

Unable to route from Modal window in AngularJS

I have a button in UI. On click on that, i am opening a bootstrap modal window. There is an another button in my modal window. I want to navigate to different route on click on that button in modal window.

$('#cartModal').modal('hide');
$location.path('/AngularJS/phonecat/#phones/address');

But it only close the modal popup, doesn't route to the given path.

Earlier route before opening the modal window: /AngularJS/phonecat/#phones Expected route after closing the modal window: /AngularJS/phonecat/#phones/address

I am unable to find that why it's not working. Kindly help.

I tried to get some code part from the main application. Hope it will help. http://jsbin.com/vizequ/2/edit?html,js

Upvotes: 0

Views: 157

Answers (2)

Devesh M
Devesh M

Reputation: 1033

It was my mistake. I was assigning the wrong path to router. On click of modal window's button, i have written the code below.

$location.path('/phones/address');
$('#cartModal').modal('hide');
$('.modal-backdrop').remove();

It solved my problem. Hope it will help others.

Upvotes: 0

Asad Palekar
Asad Palekar

Reputation: 301

Try attaching the code snippet to change routes on the hide event of the model.

$('#myModal').on('hidden.bs.modal', function (e) {
    $location.path('/AngularJS/phonecat/#phones/address');
});

If this does not help, can you post a more verbose code or a jsFiddle?

Upvotes: 0

Related Questions