1
votes

I am using gulp-angular-templacache. I have that task that should create a module named templates and I added it as a dependency to my app module:

Configurations:

templateCache: {
            file: 'tempaltes.js',
            options: {
                    module: 'templates',
                    standalone: true,
                    root: 'app/'
            }
        }

App module:

var App = angular.module('app', [
    'templates']);

Gulp task:

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

});

But, when I try to run this I am always getting that error message:

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.

I tried to make the templatescache also not standalone and removing the dependency but without success... What should I do ??

1
What is the sequence of file? - Satpal
file: 'tempaltes.js' - Oz Bar-Shalom
I am asking about the sequence of script tags - Satpal

1 Answers

0
votes

Seems you are loading template.js, after the module app definition. You can load the file before your angular app file

OR, Don't define a standalone module.

Configuration

templateCache: {
    file: 'tempaltes.js',
    options: {
            module: 'templates',
            standalone: false,
            root: 'app/'
    }
}

Angualr

//Define the module
angular.module('templates', []);
var App = angular.module('app', ['templates']);