1

Any idea why this is happening?

I try to use

ng-include="'html_template'"

URL Result WITH ng-include

http://localhost/app/grid#/leave

URL Result WITHOUT ng-include

http://localhost/app/grid#leave  

Notice that the forward slash "/" is added.

ove
  • 3,092
  • 6
  • 34
  • 51
  • Anyone has any idea? – ove Dec 11 '14 at 03:08
  • This is a mystery. no one knows why? – ove Dec 19 '14 at 16:27
  • 5
    Could you maybe provide a JSFiddle, not enough context to solve this. – Pepijn Dec 19 '14 at 16:32
  • Are you saying that using ng-include causes your page to be redirect from `http://localhost/app/grid#leave` to `http://localhost/app/grid#/leave`? It is unclear. – pasine Dec 21 '14 at 02:08
  • @pasine, using ng-include added '/' to the url instead of http://localhost/app/grid#leave it becomes http://localhost/app/grid#/leave – ove Dec 21 '14 at 05:17
  • @in_visible can you share some code? The route configuration, the included template and the controller, or anything useful. – pasine Dec 21 '14 at 09:56
  • My first guesses would be: 1) the app cannot find the template file and redirect the user to another route, or 2) the included template has a controller that redirect the user for some reason. Share some code and we will sort it out. – pasine Dec 21 '14 at 10:04

1 Answers1

1

Actually there is question and answer about that

Preserve traditional anchor behavior with ng-include

In summary of that answer, ng-include requires $anchorScroll, and $anchorScroll requires $location. As long as $location is involved, it changes the normal hash to angular hasn

This is my answer to the same problem you have, https://stackoverflow.com/a/27529032/454252

Basically Angular changes the URL with ng-include because $location service is involved, and the way get around is little tricky

Community
  • 1
  • 1
allenhwkim
  • 27,270
  • 18
  • 89
  • 122
  • This is a hacky way. I have already done similar thing by replacing the hash. looking for more elegant solution. – ove Dec 23 '14 at 08:10
  • @in_visible, if you want an elegant solution, 1) you should have asked the solution for this problem. 2) you should have listed what you have tried to solve problem. Without asking it and listing what you already knew(you might be an expert in Angular), there is no way that I know what you want. – allenhwkim Dec 23 '14 at 22:01