I am trying to generate templatecache using gulp-angular-templatecache and combine it with Angular script into one JS file.
gulp task:
gulp.task('generatetemplatecache', function () {
return gulp.src(['dev/app/**/*.tpl.html'])
.pipe(minifyHTML({quotes: true}))
.pipe(templateCache({ module:'templateCache', standalone:true }))
.pipe(gulp.dest('public/app'));
});
This is basically how output looks like:
var app = angular.module("app",['templateCache']);
angular.module("templateCache", []).run(["$templateCache", function($templateCache) {$templateCache.put("test.tpl.html","<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>My Title</title></head><body></body></html>");
$templateCache.put("layout/popover.tpl.html","<h3 class=\"popover-title\">Click</h3><div class=\"popover-content\"><table style=\"width:600px\" class=\"table\"><tr ng-repeat=\"customer in customers\"><td>{{customer.name}}</td><td>{{customer.street}}</td></tr></table>ss</div>");
But the problem is, I found that it does not load from templatecache. Everytime when angular need the template, it still grab the original template html file. If that html file is not available, then it will have trouble displaying it.
Why is it doesn't work? Any part I am doing wrong? The url in the template cache is relative to the index.html or to the root of domain?