1

I have a Angular Application, in a main.js file i have defined the app routing but i have a doubt, for example, i have a accodion menu of bootstrap, when i click about the next button:

<a href="#MainMenu" data-toggle="collapse" data-parent="#MainMenu" class="dropdown-toggle"><img src="img/ico_menu_off.png" /></a>

Due to the angular's configuration routes, the atributte href="#MainMenu", it recognizes it as a route and I not want to do anything.

This is the js code:

angularRoutingApp.config(function($routeProvider) {
    $routeProvider
        .when('/', {
            templateUrl : 'pages/home.html',
            controller  : 'mainController'
        })
        .when('/customerSearch', {
            templateUrl : 'pages/customer-search.html',
            controller  : 'customerSearchController'
        })      
        .otherwise({
            redirectTo: '/'
        });
});

How could resolved this? thanks, (i'm new in Angular)

1
  • 1
    Did you set $locationProvider.html5Mode(true) in your app config? Commented Jan 10, 2016 at 15:55

3 Answers 3

1

You shouldn't use href attribute to select accordion in your case, because it will change the URL directly as you are using anchor's href. To solve problem you should use data-target attribute instead of href

Markup

<a data-target="#MainMenu" data-toggle="collapse" data-parent="#MainMenu" class="dropdown-toggle">
   <img src="img/ico_menu_off.png" />
</a>
Sign up to request clarification or add additional context in comments.

Comments

1

You can remove the href and open it with JavaScript on click:

$("#MainMenuTrigger").click(function(){
     $('#MainMenu').modal();
});

http://getbootstrap.com/javascript/#js-programmatic-api

I suggest you also to give a look to Angular UI Bootstrap.

Comments

1

you could remove hash from URL. find this URL it will help you http://www.codeproject.com/Tips/1063634/Removing-the-sharp-Sign-from-AngularJS-URLs-with-I

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.