2017-04-08 74 views
1

我正在使用gulp-angular-templacache。 我应该创建一个模块名为templates这个任务,我增加一条,作为一个依赖于我的app模块:gulp-angular-templatecache模块不可用

配置:

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)); 

});

但是,当我尝试运行此我总是收到这个错误消息:

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也不是独立的和删除的依赖,但没有成功...... 我应该怎么做?

+0

什么是文件的顺序? – Satpal

+0

'file:'tempaltes.js'' –

+0

我在询问脚本标记的序列 – Satpal

回答

0

似乎您正在加载template.js,之后模块app的定义。您可以在角文件之前加载文件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']); 
+0

刚刚尝试过,我正在获取模块'模板'不可用 在我的index.html中,我在注入后仅注入了templates.js我的应用程序js。 –