[英]Template not loading in angular 1.5 directive
我在网站上似乎有很多这样的问题,但是没有一个对我有用。
我在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'
};
});
})();
app.js和data-table.html在目录中处于同一级别
我的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>
我的data-table.html的内容(暂时是因为我正在测试)是:
<h1>Hello world!</h1>
有人可以告诉我如何解决这个问题吗?
如果使用templateUrl,则它应相对于Web根URL; 请参考: 相对于.js文件的Angular指令templateUrl
显然问题出在我使用的另一个框架Django,因此将模板相对URL更改为绝对URL可以解决此问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.