1

我正在使用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] 模块“模板”不可用!您要么拼错了模块名称,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。

我试图使模板缓存也不是独立的并删除依赖项但没有成功......我该怎么办?

4

1 回答 1

0

似乎您正在加载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']);
于 2017-04-08T11:00:30.220 回答