I need to be able to tell an angular component to render another angular component based on dynamic data. I think this needs content projection, but I can only make content projection work in simple cases.
Example scenario
I have the following table data in vanilla TypeScript:
const headings = [
{ id: 'cat', label: 'Cat' },
{ id: 'nameIt', label: 'Type the name' }
]
const data = [
{ cat: 'Tabby', nameIt: (name) => updateTabbysName(name) },
{ cat: 'Ginger', nameIt: (name) => updateGingersName(name) },
]
I also have four Angular components:
simple-span
which renders text in a span. In this case, it will render the cat field.text-input
which renders a text input. In this case, it will render a basic HTML input which will call the nameIt callback when the user inputs text.my-special-cat-table
which will provide theheadings
anddata
variables and is allowed to know abouttext-input
andsimple-span
generic-table
which is responsible for rendering table DOM elements. It is not allowed to know thattext-input
orsimple-span
exist.
The aim is to have generic-table
completely blind to the cell render components
Is it possible to achieve this in Angular 7?
from Angular 7 Dynamic Content Projection
0 komentar:
Posting Komentar