A
A
Anton Belousov2019-04-17 11:04:43
Angular
Anton Belousov, 2019-04-17 11:04:43

How to insert EmbededView into DOM?

Hello, I have a problem when trying to dynamically generate a table. At first the problem was solved with Renderer2, but then the binding to the elements turned out to be necessary (for [disabled]) and everything went crashing. Please help.
It is necessary to insert ng-template, which is obtained in the code via @ViewChild() val: TemplateRef in the DOM element, which is accessed via ElementRef.
In this case, templates are used due to the fact that a binding to the [disabled] field is needed. ElementRef is used because of the dynamic generation of table rows and cells. (All this is needed to build a dynamic table).
Example (there should be several of them by switch ... case)

<ng template #tpl1>
<input type="number" (change)="onTopInputChange">
<input type="checkbox" (change)="onTopCheckboxChange">
</ng-template>.

If any more information is needed, I'll add it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question