我正在使用gulp-angular-templacache。我有一个任务应该创建一个名为templates的模块,并将它作为依赖项添加到我的app模块中:
组合:
templateCache: {
file: 'tempaltes.js',
options: {
module: 'templates',
standalone: true,
root: 'app/'
}
}应用程序模块:
var App = angular.module('app', [
'templates']);吞咽任务:
gulp.task('templatecache', ['clean-code'], function() {
log('Creating AngularJS $templateCache');
return gulp
.src(config.htmltemplates)
.pipe($.minifyHtml({empty: true}))
.pipe($.angularTemplatecache(
config.templateCache.file,
config.templateCache.options
))
.pipe(gulp.dest(config.temp));});
但是,当我尝试运行这个程序时,我总是会收到这样的错误消息:
未明错误:$injector:nomod模块“模板”不可用!您要么拼错了模块名,要么忘记加载它。如果注册一个模块,请确保将依赖项指定为第二个参数。
我试着使模板也不是独立的和消除依赖,但没有成功.我该怎么办??
发布于 2017-04-08 11:00:30
似乎您正在加载template.js,在模块app定义之后。您可以在角app文件之前加载该文件。
或者,不要定义独立模块。
配置
templateCache: {
file: 'tempaltes.js',
options: {
module: 'templates',
standalone: false,
root: 'app/'
}
}安圭拉
//Define the module
angular.module('templates', []);
var App = angular.module('app', ['templates']);https://stackoverflow.com/questions/43292821
复制相似问题