Brent Aureli
Brent Aureli

Reputation: 473

Angular $routeProvider not routing to nested directories

Im having problems using routeProvider to route to a subdirectory url. The Following Angular route works fine:

$routeProvider.when('/customerapi', {templateUrl: 'partials/customerApi.html', controller: 'customerApiController'});

but when I attempt to do the following:

$routeProvider.when('/projects/customerapi', {templateUrl: 'partials/customerApi.html', controller: 'customerApiController'});

everything breaks. I get the following errorerror message

I know it can find the partial, it finds it fine when the route is just /customerapi...

Im unsure why its trying to load projects/partials/customerApi.html instead of angular intercepting and loading the partial. The tag I am using to link to the partial looks like the following :

<a href="/projects/customerapi">Customer API</a>

Anyone happen to see my error?

Thanks so much!

Upvotes: 1

Views: 604

Answers (1)

p e p
p e p

Reputation: 6674

Try specifying the absolute path of the partial (note the / in front of templateUrl):

$routeProvider.when('/projects/customerapi', {templateUrl: '/partials/customerApi.html', controller: 'customerApiController'});

Upvotes: 2

Related Questions