[英]Template not loading in angular 1.5 directive
I've seem many questions like this in the site, but not of them worked for me. 我在网站上似乎有很多这样的问题,但是没有一个对我有用。
I have this in app.js 我在app.js中有这个
(function(){
var app = angular.module("freelingApp", ["ngRoute"]);
app.controller("MainController",
["$http", "$scope",
function($http, $scope){
...some code here...
}]);
app.directive("dataTable", function(){
return{
transclude:true,
replace:true,
restrict: 'E',
templateUrl:'data-table.html'
};
});
})();
Both app.js and data-table.html are at the same level in the directory app.js和data-table.html在目录中处于同一级别
My index.html is like this: 我的index.html是这样的:
<html>
<head>
... some code here ...
</head>
<body ng-app="freelingApp" ng-controller="MainController">
... some code here...
<div>
<data-table></data-table>
</div>
</body>
</html>
And the contents of my data-table.html (for the time being because I'm testing) are: 我的data-table.html的内容(暂时是因为我正在测试)是:
<h1>Hello world!</h1>
Can someone tell me how to fix this ? 有人可以告诉我如何解决这个问题吗?
If you use templateUrl, it should be relative to the web root url; 如果使用templateUrl,则它应相对于Web根URL; Please refer this: Angular directive templateUrl relative to .js file 请参考: 相对于.js文件的Angular指令templateUrl
显然问题出在我使用的另一个框架Django,因此将模板相对URL更改为绝对URL可以解决此问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.