简体   繁体   English

Angular / grunt无法加载模板

[英]Angular / grunt failed to load template

I recently introduced angular directives into my yeoman app for templating, and everything works fine if I grunt serve the normal dev version of the app, but when I build the 'dist' folder with grunt and serve it, the html in the directives of my app don't appear on the page and the console logs this error: 我最近在我的yeoman应用程序中引入了角度指令用于模板,如果我咕噜咕噜地服务于应用程序的正常开发版本,一切正常,但是当我用grunt构建'dist'文件夹并提供服务时,我的指令中的html应用程序不会出现在页面上,控制台会记录此错误:

Failed to load resource: the server responded with a status of 404 (Not Found)

vendor.6e8f248d.js:5 Error: [$compile:tpload] Failed to load template: 
/views/tabdir.html (HTTP status: 404 Not Found)

I read that dependency injection needs to be in an array format so that minification doesn't mess with it, and so I did this for all of my controllers, but the same problem still persists. 我读到依赖注入需要采用数组格式,以便缩小不会弄乱它,所以我为所有控制器做了这个,但同样的问题仍然存在。 Eg: 例如:

angular.module('MainApp').controller('MainCtrl', ['$scope', 'inputBlur', function ($scope, inputBlur) {

}]);

What is causing my directives to not be loaded correctly by grunt? 什么导致我的指令无法被grunt正确加载?

I had a similar issue. 我有一个类似的问题。 Remove the first foreslash / in the templateUrl value of your directive, should be like this: 删除指令的templateUrl值中的第一个foreslash / ,应该是这样的:

templateUrl:'views/tabdir.html'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM