Answer the question
In order to leave comments, you need to log in
How to dynamically create a view component?
Is it possible to dynamically create a view component in Angular 2?
The task is such that under certain conditions it is necessary to create new pages with their own functionality. Creating all the components and prescribing routes on the front is not an option, you need it dynamically. Is this even possible?
Answer the question
In order to leave comments, you need to log in
Hey!
Describe the task in more detail. Now you can be understood in two scenarios:
1) So that the application works out any routes, this option is suitable if the functionality is almost the same everywhere, and here I would not look at angular at all, but would consider server rendering.
2) Certain conditions are the parameters of the router, here you need to look towards structural directives and read about ViewContainerRef, viewContainerRef.createEmbeddedView(this.templateRef)
Where, for example, there will be 1 routing and, depending on the parameters, slip the required templateRef (in this case, this is a component).
But how to create a super component for all cases is a question)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question