Reputation: 895
Here is my directive
(function() {
angular.module('commentsDirective', [])
.directive('mngComments', mngComments)
function mngComments() {
return {
restrict: 'AE',
scope: {
moment: '='
},
templateUrl: 'comments.html',
replace: true,
controller: 'CommentsController',
controllerAs: 'vm'
};
};
})();
Here is my file structure:
And I get this error message:
I'm not understanding this. My html file is in the same directory as my directive so why can't it find it?
Upvotes: 0
Views: 899
Reputation: 479
Path to template should be relative to page’s path. So if directory comments is placed at root, you should specify templateUrl as /comments/comments.html.
If you want to use your module in unknown paths, you can use $templateCache to “import” your template to your module first. Then you can specify custom URL used while defining templateCache.
Upvotes: 2