我正在使用gulp-angular-templacache
。
我的任务应该创建一个名为 templates
的模块,并将其添加为我的 app
模块的依赖项:
配置:
templateCache: {
file: 'tempaltes.js',
options: {
module: 'templates',
standalone: true,
root: 'app/'
}
}
应用程序模块:
var App = angular.module('app', [
'templates']);
gulp 任务:
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));
});
但是,当我尝试运行此程序时,我总是收到该错误消息:
Uncaught Error: [$injector:nomod] Module 'templates' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
我尝试使 templatescache 也不再独立并删除依赖项,但没有成功...... 我该怎么办??
最佳答案
似乎您正在加载 template.js,在模块 app
定义之后。您可以在 Angular app
文件
或者,不要定义独立模块。
配置
templateCache: {
file: 'tempaltes.js',
options: {
module: 'templates',
standalone: false,
root: 'app/'
}
}
Angualr
//Define the module
angular.module('templates', []);
var App = angular.module('app', ['templates']);
关于javascript - gulp-angular-templatecache 模块不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43292821/