我想将 templateUrl 的路径作为单独的 .jade 文件给出。但它显示 500 err 和 Error: [$compile:tpload] 。
下面是我的指令中的代码
app.directive('personRecord',['$http',function(http){
return{
restrict : 'AE',
templateUrl : '../../views/template.jade',
link : function(scope,ele,attr){
}
}
}]);
我的文件夹结构如下所示。
bin
node_modules
public
|-- js
|-- main.js
routes
views
|-- template.jade
|-- index.jade
app.js
package.json
请帮我解决这个问题!我在这里缺少什么!
最佳答案
我的建议是将 View 文件夹放在公共(public)文件夹中:-
bin
node_modules
public
|-- js
| |-- main.js
|--views
|-- template.jade
|-- index.jade
routes
app.js
package.json
然后使用
app.directive('personRecord', function(http){
return {
restrict : 'AE',
templateUrl : 'views/template.jade',
link : function(scope, ele, attr){
}
};
});
希望有帮助:)
关于javascript - angularJs 指令中 templateUrl 的正确路径应该是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30952600/