I have two nested directives in my AngularJS project. The HTML is the following:
<body ng-app="main">
<mainapp></mainapp>
</body>
An the main.js is the following:
var mainDirective = angular.module('main',
[
'app.config',
'app.ui.menu'
]);
mainDirective.directive('mainapp', [
'ConfigService',
function(config)
{
return {
restrict : 'E',
templateUrl : config.path.views + '/index.html'
}
}
]);
The content of the template is the following:
<menu-index></menu-index>
<div class="ui basic segment">
<div class="ui vertically padded grid">
More html here
For some reasons the app.ui.module is not working properly (I know that is included because I don't receive any error). This is the 'app.ui.module':
var menuIndex = angular.module('app.ui.menu', ['app.config']);
menuIndex.directive('menu-index', ['ConfigService', function(config)
{
return {
restrict : 'E',
templateUrl : config.path.views + '/menu/index.html'
}
}]);
I don't know why the first <main></main> directive is working but the second <menu-index></menu-index> (the nested one) is not.
mainis a standard HTML5 tag. I think that shouldn't interfere with your using it as a directive, but for clarity it might be better to rename it.divtags and close them in a subsequent template. I think the browser is going to insert</div>tags here automatically.<mainapp></mainapp>to<main-app></main-app>the whole main module is not working anymore. Furthermore there are no HTML fragments, I just didn't write the code for the whole page to make the question easier to read.