I have this small gridComponent:
@Component({
selector: 'moving-grid',
templateUrl: './grid.component.html',
styleUrls: ['./grid.component.css']
})
export class GridComponent {
@Input('widgets') extComponents: Array<Component>;
}
And a second testComponent
@Component({
selector: 'test',
template: `
<div #content>I say hello<li>i</li><li>u</li><button (click)="test()">click me</button> world</div>
`
})
export class TestComponent {
@ViewChild('content') content: HTMLElement;
getContent() {
return this.content;
}
test() {
console.log("test");
}
}
Now I'm trying to pass multiple instances of testComponent to the gridComponent. Therefore I have a third Component which looks like this one:
selector: 'moving-grid-container',
template: `
<moving-grid [widgets]="[z1,z2]">
<test class="grid-item-content-001" #z1></test>
<test class="grid-item-content-002" #z2></test>
</moving-grid>
`
Until this point, everything works like expected. But how can I render the Components from @Input in the gridComponent? My first approach was to declare a @ViewChild in the testComponent and return it with a getContent()-function. But it won't work. Can I use the ng-content directive in some way or is there a better solution?
The GridComponent looks like this. I want to display the templates of a @Input-Component inside one of the black boxes. Is it possible?
Thanks for any kind of help