Angular / grunt无法加载模板 [英] Angular / grunt failed to load template
问题描述
我最近将角度指令引入到我的yeoman应用程序中进行模板化,并且如果我咕噜为应用程序的正常开发版本提供服务,但一切正常,但是当我用grunt构建dist文件夹并将其提供时,我的应用程序的指令不会出现在页面上,并且控制台会记录此错误:
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:
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)
我读了依赖注入需要是数组格式,没有弄乱它,所以我为我的所有控制器做了这个,但同样的问题仍然存在。例如:
$ b
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) {
}]);
是什么导致我的指令无法通过grunt正确加载?
What is causing my directives to not be loaded correctly by grunt?
推荐答案
我有类似的问题。删除指令的 templateUrl
值中的第一个预期值 /
应该是这样的:
I had a similar issue. Remove the first foreslash /
in the templateUrl
value of your directive, should be like this:
templateUrl:'views/tabdir.html'
这篇关于Angular / grunt无法加载模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!