I was thinking about creating small component in Angular that will do what <ng-include>
is doing in angularJS.
First, I must give component a template or templateUrl for compiling? What if it something I will know only in run time?
@Component({
selector: 'my-template',
// templateUrl: '', //won't render, must give it something?
})
export class MyTemplate {
@Input() templateURL: string;
constructor() {
console.log("template component was created!");
}
}
I want to create instance of that component in code and give its templateUrl. Something like that:
var factory = this.resolver.resolveComponentFactory(MyTemplate);
factory.templateUrl = // Is that possible?
Can it be done somehow? the templateUrl is something that will come from @input How in code I create instance of component and give it its input?