Maybe I'm fundamentally misunderstanding something, but I'm trying to get a TemplateRef pointing to my Component's template (simply 'Hello' in the bare-bones example below). I've stripped my code down to the bare minimum to try to identify the problem:
import { Component, TemplateRef} from '@angular/core';
@Component({
selector: 'app-root',
template: `Hello`,
styleUrls: ['./app.component.css']
})
export class AppComponent implements AfterViewInit {
constructor(private tr: TemplateRef<any>) {}
}
This doesn't actually "do" anything as I've removed all functionality, but I would have expected this to work. When I run this code, I get an error: No provider for TemplateRef and yet I see examples on SO and elsewhere where this apparently works. What am I missing?
Angular 4.2.4
Thanks.