Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using the ui-bootstrap module in my AngularJS project. Before I open the modal the url looks like this : localhost:58890/#/Project/46. The code that opens it is here :

$modal.open(modalServices.newItemModal).result.then(function (name) {
                    var folder = new Item({
                        id: null,
                        projectId: ProjectService.project.ID,
                        name: name,
                        type: ItemType["Folder"],
                        contents : null
                    });

The modalServices.newItemModal settings are here :

var newItemModal = {
    templateUrl: '/template/modal/newItem',
    controller: 'NewItemController',
    backdrop: 'static',
    size : 'sm'
};

after the line of code $modal.open the url changes to : localhost:58890/ Is it possible to prevent this, and make the modal act like in the jQuery modal where it doesn't change the url ?

share|improve this question
    
How are you triggering the modal open from the html? I have an application locally ( triggering it with a button ) and it does not change the location hash by default –  Philipp Jun 18 at 8:43
    
Uh.... it's triggered by clicking on a contextMenu directive that i downloaded, and it is implemented with <a href="#"> etc etc</a> so ye .... I changed the directive and it worked, :) Thanks! –  Shtiliyan Uzunov Jun 18 at 9:04
add comment

1 Answer 1

up vote 1 down vote accepted

If you are calling your modal open function from a anchor tag , DONT!

define a buttton in your view and in on-click event , fire the open modal function like this :

    <button ng-click="openmodal()">OPEN MODAL</button>

    app.controller('YourCtrl',function($scope,$modal){

    $scope.openmodal=function(){
        $modal.open(modalServices.newItemModal).result.then(function (name) {
                var folder = new Item({
                    id: null,
                    projectId: ProjectService.project.ID,
                    name: name,
                    type: ItemType["Folder"],
                    contents : null
                });

        }
       });
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.