Accessing @ViewChild template from ng content
Is it possible to use templates in combination with ng-content as described here:
application component:
<table-column>
<template #template let-item="item">
<input type="text" [(ngModel)]="item.foo" />
</template>
</table-column>
table-column component:
@Component({
selector: 'table-column',
template: '<ng-content></ng-content>'
})
export class TableColumnComponent implements OnInit {
@ViewChild('template') template;
ngOnInit() {
console.log(this.template); // undefined
// create column object with template and different metadata...
});
}
Plunker ?
Problem: I am getting undefined
using different lifecycle hooks (ngOnInit, ngAfterViewInit) ...
+3
source to share