I am trying to create a sidebar dynamically. Which can be collapsed or expanded by clicking the menu item. Using
<div [innerHtml]="function()"></div>
works. But the submenus are collapsed as it should be. But it does not expand when you click on it. Getting errors.
When I tried to use dynamic components <ng-template sideBarPage></ng-template>
, it is collapsed, but I get the following error. Don't know if it is expecting a router map.
injector.ts:1 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'subMenu1'
Error: Cannot match any routes. URL Segment: 'subMenu1'
Also I tried with encapsulation: ViewEncapsulation.Native
. When Native mode is used all the submenus are expanded and clicks do not work.
I have created a sample here https://embed.plnkr.co/mn8gKcBzJLD4StrN5SmP/
The "Sidebar Item 2" should be collapsed and on click expand.
I am new to Angular. Any help is appreciated. Thanks
Yes, when you click on the sidebar item2 the link shows correctly. But it doesn't expand. Which, I am not able to show on plunkr. But when I run directly from WebStorm and open it in Google Chrome, neither it shows the downward-caret, nor when you click on it, it opens (expands) the submenu. – Shriram M. Oct 30 '17 at 06:03