2017-04-08 72 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。 –