I'm wondering - how to make a Directive with dynamic template.
The thing is - When I'm on the main page and main categories like page1 or page2 my template should have all the divs
When I'm on the submenu like subpage1 or subpage2 I want to have only 3 divs.
How to dynamically achieve it? I know that I have to use on each subpage my directive
<my-template whereIam="page1"></my-template> or <my-template whereIam="subpage2"></my-template>
But I can't achieve it. Could you help me?
My directive with example template:
angular.module('dynamic-template').directive('myTemplate', function () {
return {
restrict: 'E',
template: "<div1> "
+ "<h1> Main pages and subpages </h1>"
+ "</div1>"
+ "<div2>"
+ "<h2> Main pages and subpages </h2>"
+ "</div2>"
+ "<div3>"
+ "<h3> Main pages and subpages </h3>"
+ "</div3>"
+ "<div4>"
+ "<h4> Only mainpages </h4>"
+ "</div4>"
+ "<div5>"
+ "<h5> Only subpages </h5>"
+ "</div5>"
};
}]);
HTML on one of the pages:
<my-template whereIam="??" ></menu-template>
Example Plunkr
http://plnkr.co/edit/kVk3mJWUbTqhFEHVUjt1?p=preview
I have searched for this, but I'm lost :(
Have I use a $compile to achieve it?