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-spanwhich renders text in a span. In this case, it will render the cat field.text-inputwhich 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-tablewhich will provide theheadingsanddatavariables and is allowed to know abouttext-inputandsimple-spangeneric-tablewhich is responsible for rendering table DOM elements. It is not allowed to know thattext-inputorsimple-spanexist.
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