我的路线是这样定义的:
$routeProvider
.when('/settings', { templateUrl: 'settingsTemplateURL', controller: settingsCtrl })
.when('/profile', { templateUrl: 'profileTemplateURL', controller: profileCtrl })
.otherwise({ redirectTo: '/settings' });
我在这样的地址上使用我的 webb:localhost/testapp/#/settings 或 localhost/testapp/#/profile 等等...
当我请求地址: localhost/testapp 时,问题就开始了。 此时,否则函数会将我重定向到 localhost/testapp#/settings,其中“testapp”后面的斜杠丢失。这是AngularJS版本之间的差异,因为这个问题是在AngularJS从版本1.0.7更新到1.2.13后出现的
请问有人可以帮我吗? 谢谢大卫
最佳答案
问题是localhost
。
尝试使用: http://127.0.0.1/
而不是 localhost
此外,当 $.route 尝试恢复模板时,您可能仍然会遇到问题,有时它不起作用,因为未发送正确的 header ,但这取决于您的设置。
成功了吗?
关于javascript - AngularJS 否则函数将我重定向到错误的路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22011854/