我试图在我的角度应用中实现HTML5推送状态,但无济于事。 (我可以通过输入确切的路径(例如http://localhost/components/profile/profile.html
)访问每个静态文件,但是当我尝试通过templateUrl
选项在状态定义中加载模板时,它不会加载任何内容。在控制台的错误也不是我的路线设置正确模板加载时出现一些奇怪的问题
值得一提的是:?切换到profile
状态,当我看到在服务器profile.js
要求,但模板没有要求
快速路线:
应用程序配置:
function lazyLoad(pathjs) {
return ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load(pathjs);
}];
}
$stateProvider
.state('home', {
url: '/',
template: 'Welcome home'
})
.state('profile', {
url: '/profile',
templateUrl: 'components/profile/profile.html',
controller: 'profileCtrl',
controllerAs: 'vm',
resolve: {
module: lazyLoad('components/profile/profile.js'),
user: ['SessionService', function (SessionService) {
return SessionService.currentUser();
}]
}
});
$locationProvider
.html5Mode(true)
.hashPrefix('!');
项目树:
问题仍然存在,html5mode设置为false。 –
@itdoesntwork,这应该是对问题的评论,而不是回答。 –
我知道,但我需要更多的声誉来评论:( – itdoesntwork