I started doing some research into using Angular2 and one of the questions I had that I can't find a solution for. I have a requirement that depending on the data I receive from my model, I wish to load different templates for a given component. This is mainly related to maintaining different layouts depending on the data I receive. Is this possible?
Thanks
Angular 2 favors component composition approach to UI building. Because of this you shouldn't really end up with huge templates and if so it's maybe better idea to split them up into some helper sub-components (even if they provide nothing but layout).
In cases when template isn't really big you can conditionally render based on some component's property with *ngIf
directive.
Another way to approach this would be to implement routes on that component level and then programatically route to these routes after you received the data with router.navigate(['./MySubcomponent'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With