How I can use component as input data for another component in Angular?
For example:
I want bulid table component AppTableComponent:
<app-table [dataSource]="dataSource" [columns]="columns">
<ng-container tableColumnDef="actions">
<a routerLink="/model/edit/{{item.id}}" routerLinkActive="active">Edit</a>
<a routerLink="/model/delete/{{item.id}}" routerLinkActive="active">Delete</a>
</ng-container>
<ng-container tableColumnDef="isActive">
<div [ngClass]="{cercl:true, 'is-active':item.is_active}"> </div>
</ng-container>
</app-table>
dataSource
is data array sumthing like Model[]
or Person[]
or Car[]
. columns
is a string array like ['id', 'isActive', 'name', 'actions']
. It should containt dataSource rows attibutes names or addition columns names.
I know how I can use ng-content
but it's not samular case. Difference is I should use parts of content in sereral places. Perhaps I should use ng-contet, but I don’t know something.
I'm sure my goal is posible becouse Angular material table work like this:
<mat-table #table [dataSource]="dataSource">
<ng-container matColumnDef="position"></ng-container>
<ng-container matColumnDef="weight"></ng-container>
</mat-table>
Please don't propose me use Angular material table component. I don't need table. I just want to learn something new.
I'll be thenkful any information or article about topic!