使用gulp的Angularjs中的templateCache模板URL错误

时间:2016-03-19 05:27:56

标签: javascript angularjs node.js gulp angular-templatecache

enter image description here Gulp构建后加载的模板URL错误。我希望模板URL应该是$ templateCache.put('scripts / app / cinemasList / cinemasList.html'),但实际是$ templateCache.put('scripts / cinemasList / cinemasList.html')

gulp.task('ngtemplate', function() {
 return gulp.src(config.srcTemplates)

.pipe($.minifyHtml({
  empty: true,
  spare: true,
  quotes: true
}))
.pipe($.ngHtml2js({
  template: "    $templateCache.put('<%= template.url %>',\n        '<%= template.prettyEscapedContent %>');",
  prefix: 'scripts/'
}))
.pipe($.concat('templates.js'))
.pipe($.tap(function(file, t) {
  file.contents = Buffer.concat([
    new Buffer("(function(module) {\n" +
      "try {\n" +
      "  module = angular.module('myApp');\n" +
      "} catch (e) {\n" +
     // "  module = angular.module('myApp', []);\n" +
      "}\n" +
      "module.run(['$templateCache', function($templateCache) {\n"),
    file.contents,
    new Buffer("\n}]);\n" +
      "})();\n")
  ]);
}))


.pipe(gulp.dest(config.scripts + 'templates'));

});

0 个答案:

没有答案