0

i m using location.path to navigate like

$location.path('#/foo');

while in app I am using route provider like

var app = angular.module("myApp", ['ngRoute'])
    .config(function($routeProvider){
    $routeProvider
    .when("/foo",{
        templateUrl: "templates/foo.html",
        controller: "fooController"
    })
    .otherwise({
    template : "<h1>None</h1><p>Nothing has been selected</p>"
    });
   });

but instead of producing url like

http://localhost:8001/#/foo

location.path traverses to

http://localhost:8001/#/%23/foo

and hence routeprovider is loading otherwise template and not the required template doesn't loads. How can I check that

Sakky
  • 84
  • 10

2 Answers2

1

Remove explicit # from your route in $location.path('#/foo'); and change it to $location.path('/foo');

because angular itself append # tag during route, which already seen in your question http://localhost:8001/#/%23/foo, and when you give explicit one, then it encodes to %23

anoop
  • 3,812
  • 2
  • 16
  • 28
1

Just get rid of the # you put in $location.path(). It's already added by default.

$location.path('/foo');
Manas
  • 808
  • 1
  • 7
  • 16