Take a look at my project structure below
project
-Lib
-MyCustomDirective (to be used in various applications)
-customDir.js
-customDirTmpl.html
-app
-js
-myfirstcontroller.js
-main.js
-partials
-myfirstview.html
-index.html
As I plan to create a custom directive for use across multiple projects, I face an issue. I aim to store the template for my directive in a separate HTML file. However, upon loading the directive, my app tries to locate "customDirTmpl.html" relative to the current application rather than within the "MyCustomDirective" folder.
I wish to maintain the templateUrl of my directive consistent across all projects, without needing to adjust it for each specific project.
Here's a snippet from "customDir.js"
var myDir = function () {
return {
restrict: 'E',
//I want this to remain constant no matter which project uses this directive
templateUrl: 'customDirTmpl.html',
link: function(scope){
//do something here
}
};
};
app.directive("MyCustomDir", [myDir]);