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

Kia Panahi Rad
  • 1,235
  • 2
  • 11
  • 22

2 Answers2

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.

Community
  • 1
  • 1
callmekatootie
  • 10,989
  • 15
  • 69
  • 104
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

Kia Panahi Rad
  • 1,235
  • 2
  • 11
  • 22