Angular UI 使用 grunt 构建后路由器不使用模板缓存
Angular UI Router not using template cache after building with grunt
使用 Grunt 构建我的应用程序后,ui.router 仍在尝试访问 templateUrl url。由于这些已被 ngTemplates 连接起来,所以这不起作用,我只收到一些 404 错误。
我是新手,不太明白我在做什么
$stateProvider
.state("home", {
url: "/",
views: {
'master': {templateUrl: '/views/main.html'},
"view-left@home": {
templateUrl: '/views/list.html'
},
"view-right@home": {
templateUrl: '/views/page.html'
}
}
})
这在我使用 grunt serve 时有效,但在我构建应用程序时中断
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (main.html, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (page.html, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (list.html, line 0)
如果您需要更多信息,请告诉我,我不太确定什么是相关的。
编辑:
grunt.registerTask('build', [
'clean:dist',
'wiredep',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'ngtemplates',
'concat',
'ngAnnotate',
'copy:dist',
'cdnify',
'cssmin',
'uglify',
'filerev',
'usemin',
'htmlmin'
]);
这是我的构建任务。
我好像修好了。问题是在我的状态下,templateUrl 是 '/views/main.html'
,但在 templateCache 中它是 'views/main.html'
(没有第一个斜杠)。从 templateUrls 中删除第一个斜杠解决了这个问题。
使用 Grunt 构建我的应用程序后,ui.router 仍在尝试访问 templateUrl url。由于这些已被 ngTemplates 连接起来,所以这不起作用,我只收到一些 404 错误。
我是新手,不太明白我在做什么
$stateProvider
.state("home", {
url: "/",
views: {
'master': {templateUrl: '/views/main.html'},
"view-left@home": {
templateUrl: '/views/list.html'
},
"view-right@home": {
templateUrl: '/views/page.html'
}
}
})
这在我使用 grunt serve 时有效,但在我构建应用程序时中断
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (main.html, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (page.html, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (list.html, line 0)
如果您需要更多信息,请告诉我,我不太确定什么是相关的。
编辑:
grunt.registerTask('build', [
'clean:dist',
'wiredep',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'ngtemplates',
'concat',
'ngAnnotate',
'copy:dist',
'cdnify',
'cssmin',
'uglify',
'filerev',
'usemin',
'htmlmin'
]);
这是我的构建任务。
我好像修好了。问题是在我的状态下,templateUrl 是 '/views/main.html'
,但在 templateCache 中它是 'views/main.html'
(没有第一个斜杠)。从 templateUrls 中删除第一个斜杠解决了这个问题。