Rajith Gun Hewage
Rajith Gun Hewage

Reputation: 532

redirecting from a modal using ng-click and the data-dismiss doesn't work

I was trying to navigate from a modal in a page to another page by adding a function to ng-click. When I remove the function assigned to ng-click, the data-dismiss works properly and the modal gets removed. But when I use the ng-click with a function, which redirects to an alternative page, it gets directed to the page, but the modal has not been dismissed. (the new page seems in the disabled state)

<button type="button" class="btn btn-success" ng-click="addNewProject()" 
data-dismiss="modal">Add Project</button>

The addNewProject() function redirects to the other page and adds the details in the modal to the database. I would like to know a way to get the page which was loaded later, in the editable way. (the modal should be completely removed.)

Upvotes: 5

Views: 9283

Answers (2)

Rajith Gun Hewage
Rajith Gun Hewage

Reputation: 532

$(".modal-backdrop").hide();

Adding the above line in the ng-click function got rid of the issue.

Upvotes: 13

4dgaurav
4dgaurav

Reputation: 11496

Please have a look at http://angular-ui.github.io/bootstrap/

  1. Refer Closing Twitter Bootstrap Modal From Angular Controller

    $scope.close = function(result){ dialog.close(result); };

or

  1. use this inside ng-click function

    $('#myModal').modal('hide');

Upvotes: 1

Related Questions