0

I'm having a problem with angular routing mechanism:

$routeProvider
  .when("/", { templateUrl: "/*some MVC calls to return a partial view*/"})
  .when("/somewhere/:someParams", { templateUrl: "/*some MVC calls to return a partial view*/"})
  ...
  .otherwise({redirectTo: "/"})

The problem is I'm using a wrapbootstrap's theme (more accurately the Ace) and it has lots of functionality based on <a> tags and href="#" attributes and whenever the user clicks an element (like the dropdown menus which also have a <a href="#"> tag), angularjs jumps in and tries to parse the url which looks like this most of the time: http://localhost/site/somewhere/someParams#

any suggestions on how to separate these two functionality?

thanks in advance

2 Answers 2

1

You can take a look at the answer here. The approach is to have a directive that will prevent the default action (in your case, navigating to "/#").

You can modify the directive to navigate only when the location is not "/#". Using the attrs parameter in the function (see the accepted answer for the above question) identify the value of the href attribute. Based on its value you can then chose to proceed normally or to prevent the browser from navigating to the URL.

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

1 Comment

Thank you for your suggestion. You may chech my question's answer if you like.
0

Actually I found my answer today while reading AngularJS's docs. the <a> tag is already a directive in angular and it's written so that when given an empty href (<a href="">) it prevents the default behavior of the a tag

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.