Reputation: 341
(function () {
var app = angular.module('footer', []);
app.directive('siteFooter', function () {
return {
restrict: 'E',
templateUrl: 'site-footer.html',
};
});
})();
(function () {
var app = angular.module('footer', []);
app.directive('siteFooter', function () {
return {
restrict: 'E',
templateUrl: 'Hexdra/partials/site-footer.html',
};
});
})();
I have an app that controls just the footer of my site, I then inject that footer app into the main app that defines my page.
I use the templateUrl
to load a template for the footer.
For the first case I'm confused because the footer
app is not in the same directory as the template it's linked to, and it's still able to find it.
For the second case when the template has to be defined as 'Hexdra/partials/site-footer.html'
, why does it require me to go to the root?
If my files are structured as
- Hexdra
- -> app - contains the angular.Js files
- -> assets
- -> partials - contains my site-footer.html file.
- html-files
wouldn't I need to use 'partials/site-footer.html'
?
Upvotes: 0
Views: 28
Reputation: 1417
First I'm confused because the footerapp is not in the same directory as the template its linked to, and it is still able to find it
That's a javascript feature.
Second, for the second case when the template has to be defines as 'Hexdra/partials/site-footer.html', why does it require me to go to the root?
The template is loaded with respect to the directory for index.html as the root, because the template is references by your script and your script files are loaded from index.html.
As a stand alone app, your script is loaded from the footer template and hence the root is the directory of the footer template.
Upvotes: 1