Search code examples
jqueryangularjsangularjs-directiveangularjs-ng-repeatangularjs-ng-include

nginclude add / to the main url


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.


Solution

  • 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