2

i am using bootstrap LTR 3.1.1 in an angularjs SPA project. i am using this code to create dropdown menu in my application:

bootstarp dropdown menu example

but when i click on dropdown link Submenus wont appear and my app will redirect to its root directory.

how can i resolve this problem?

1 Answer 1

1

We had a similar problem on a project with angular + bootstrap where dropdown elements would redirect to root. We changed the

<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>

into

<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>

The href="#" is indeed referring to the root of your app, removing that and replacing it with that removes the link while maintaining the pointer cursor. Alternatively, you could add a CSS class like

.pointerCursor {
  cursor: pointer;
}

and replace the <a> tag with a <span> tag and append the class to the new span element.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you ... it was useful for me .....another solution is using angular-strap or using ui-router or angular-ui but your suggest was short and easy .... :)

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.