我在java动态web项目中耗尽了我的angular应用程序,目录映射:
->WebContent
---->javaScript
------>directives
index.html在我的指令文件夹中,我有form directive:
var app = angular.module('myApp');
app.directive('formDirective', formDirective);
function formDirective() {
var directive = {
restrict: 'EA',
templateUrl: 'formDirective.html', //the request
scope: {
},
controller: FormControllerDir,
controllerAs: 'vm',
bindToController: true
};
return directive;
}
function FormControllerDir() {
console.log('FormController');
}和formDirective.html放在相同的目录下,但角度搜索根目录下的文件:
GET http://localhost:8080/P2P/formDirective.html 404 (Not Found)P2P是我的工程名,怎么改成:
http://localhost:8080/P2P/JavaScript/directives/formDirective.html发布于 2017-07-04 20:23:37
所以它很简单,只需从上下文中添加完整路径-
templateUrl: 'JavaScript/directives/formDirective/formDirective.html'
https://stackoverflow.com/questions/44904464
复制相似问题