[英]AngularJS RouteProvider not working correctly
$routeProvider.when('/home', {
templateUrl: 'index.php/projects/projects/contact',
controller: 'home'
});
$routeProvider.otherwise({ redirectTo: '/home' });
I cannot seem to get the templateUrl to pull in the correct URL. 我似乎无法让templateUrl输入正确的URL。 It seems to only redirect back to /home. 似乎只能重定向回/ home。 Does anyone know what I'm doing wrong? 有人知道我在做什么错吗?
Please show your working directory structure. 请显示您的工作目录结构。 I think templateUrl should not include index.php
. 我认为templateUrl不应该包含index.php
。 Try, 尝试,
$routeProvider.when('/home', {
templateUrl: 'projects/projects/contact.html',
controller: 'home'
});
$routeProvider.otherwise({ redirectTo: '/home' });
Yor Calling path, index.php/projects/projects/contact
, may be wrong. 您的调用路径index.php/projects/projects/contact
可能是错误的。 Just use projects/projects/contact/index.php
. 只需使用projects/projects/contact/index.php
。
The code can also be simplified as follows, instead of calling $routeProvider
twice. 该代码也可以简化如下,而不是两次调用$routeProvider
。
$routeProvider.
when('/home', {
templateUrl: 'projects/projects/contact/index.php',
controller: 'home'
}).
otherwise({
redirectTo: '/home'
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.