var app = angular.module('home', []);
app.controller('articleController', ['$scope', function($scope) {
$scope.title = "elad";
$scope.writer = "elad";
$scope.content = "bla bla bla bla bla";
}]);
app.directive('drArticle', function() {
return {
templateUrl: '/app/shared/article/Views/articleView.html'
};
});
templateUrl
正试图通过此网址访问html文件:
http://127.0.0.1:56911/app/componenets/home/app/shared/article/Views/articleView.html
该文件实际位于:
http://127.0.0.1:56911/app/componenets/home/views/index.html
如何修复路径:
http://127.0.0.1:56911/app/shared/article/Views/articleView.html
答案 0 :(得分:0)
尝试这种方式怎么样?
templateUrl: currentScriptPath('articleView.html')
<强>更新强>
抱歉,我忘了添加一些代码,结果应该是这样的:
var currentScriptPath = scripts[scripts.length-1].src;
var app = angular.module('home',[]);
app.controller('articleController', ['$scope', function($scope) {
$scope.title = "elad";
$scope.writer = "elad";
$scope.content ="bla bla bla bla bla";
}]);
app.directive('drArticle', function() {
return {
templateUrl: currentScriptPath('articleView.html')
};
});