Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用gulp的Angularjs中templateCache的模板URL错误_Javascript_Angularjs_Node.js_Gulp_Angular Templatecache - Fatal编程技术网

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

Javascript 使用gulp的Angularjs中templateCache的模板URL错误,javascript,angularjs,node.js,gulp,angular-templatecache,Javascript,Angularjs,Node.js,Gulp,Angular Templatecache,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({ 空:

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({
空:是的,
是的,
引用:对
}))
.pipe($.ngHtml2js({
模板:“$templateCache.put(“”,\n“”);”,
前缀:“scripts/”
}))
.pipe($.concat('templates.js'))
.pipe($.tap(函数(文件,t){
file.contents=Buffer.concat([
新缓冲区((函数(模块){\n“+
“请尝试{\n”+
“模块=角度。模块('myApp');\n”+
“}捕获(e){\n”+
//module=angular.module('myApp',[]);\n+
“}\n”+
module.run(['$templateCache',function($templateCache){\n”),
file.contents,
新缓冲区(“\n}]);\n”+
“})(;\n”)
]);
}))
.pipe(gulp.dest(config.scripts+模板));

}))

你能分享你的应用程序的目录结构吗?嗨,我已经添加了屏幕截图。我的html位于应用程序文件夹下,模板将位于模板文件夹中。您能否显示
app
目录的目录结构?
gulpfile
位于何处?gulpfile位于www目录的正外部..I guest运行任务时,脚本将移动到app文件夹中。您可以尝试放置前缀:“脚本/应用程序”
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'));