At the end of my wits here, so reaching out to smarter people. I am building a custom "tabbed" CMS system. Problem is with tabs and components. I wish to show a specific component in newly generated tab, in other words, I wish to load components dynamically. To clarify:
In picture 1 we see our layout, we have left sidebar with links, Tab holder, where opened tabs are shown, and Content holder, where we show loaded tab contents.
In picture 2 we see our layout, when I have clicked on "Help" link in sidebar. A tab with its title is created in tab holder area, and its content loaded into content area.
What I need:
- Tab "Dashboard" is active by default and unclosable.
- When I click on "Help" link in sidebar, I wish to initialize HelpComponent loading. I want to create tab with title "Help" in tab holder area and in content area load that components template & data NEXT to dashboards template, NOT overriding it.
- I want to freely jump across tabs, basically show/hide happens on the content there. Tab and its content are removed from DOM only when i press x in tab.
- Url represents where u are, if I'm in dashboard: localhost/dashboard, if I'm in help: localhost/help.
What are the best options to make this a reality?
Can I somehow setup this system using router links or should I make a function in SidebarComponent, which reads the element I clicked, gets its attribute "data-href" and then somehow manually initialize component load / route change?
Some very basic plunkers showing this in action would be GODLY!
p.s. The things I researched mostly reffered to DynamicComponentLoader(DCL), but that is deprecated now and replaced by ElementRef and ViewContainerRef (http://blog.lacolaco.net/post/dynamic-component-creation-in-angular-2/), but I can't find an example appropriate enough to understand how to apply it to my situation.
This, however, was a little bit closer to what I needed - code there->
- http://plnkr.co/edit/MMy3azc4ksQOH6ezZIG5?p=preview. It loads component on demand and then simply reuses them (show/hide). But it seems that was built on the old router-deprecated module.