角$ routeProvider不是路由到嵌套目录 [英] Angular $routeProvider not routing to nested directories
问题描述
即时通讯使用routeProvider路由到一个子目录网址有问题。
以下角航线正常工作:
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 error
我知道它可以找到部分,它发现它很好,当路由只是/ customerapi ...
I know it can find the partial, it finds it fine when the route is just /customerapi...
林不能确定为什么它试图加载的项目/谐音/ customerApi.html而不是角拦截和加载部分。我使用的标签链接到的部分如下所示:
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?
太感谢了!
推荐答案
尝试指定部分的 /
在前面的绝对路径(注意 templateUrl
)
Try specifying the absolute path of the partial (note the /
in front of templateUrl
):
$routeProvider.when('/projects/customerapi', {templateUrl: '/partials/customerApi.html', controller: 'customerApiController'});
这篇关于角$ routeProvider不是路由到嵌套目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!