I want to do something like this in app.component:
<app-table-container [data]="tableData">
<app-some-table></app-some-table>
</app-table-container>
table-container.component.html
<!-- stuff that also needs data-object -->
<ng-content [data]="data"></ng-content>
table-container.component.ts
@Input() data: ITableStuff;
some-table.component.ts
@Input() data: ITableStuff;
This doesn't work
I can pass the tableData to both in app.component but I'd like to pass it only to table-container and from there to projected content.
You can "reach" the parent using in constructor of app-some-table and use a getter (not an input)
You can also, instead use a getter assign the value in ngAfterViewOnInit
See stackblitz (in the stackblitz is the second option, I enclosed in a setTimeout when equal the data to avoid the error "Expression has changed after it was checked")
Update another approach is use ContentChild.
In our parent
And in ngAfterViewInit
But this approach need know the "childComponent" class. Always can extends all the possibles child from a component base and ask about "ChildComponentBase"