I am facing the following (apparently simple) situation:
@Component({
selector: 'my-component',
template: `
<p>{{text}}</p>
`,
})
export class MyComponent implements OnInit {
public text: string;
constructor(
private route: ActivatedRoute,
private apiService: ApiService
) {}
@Input() id: number;
ngOnInit() {
this.route.params.subscribe(params => {
this.text = this.apiService.getText(id);
});
}
}
The variable text
comes from a CMS and can contain manually written instances of routerLink
(well, actually of a custom directive that extends routerLink
).
Is there any non hacky way to make those directives compile, when ngOnInit
is called? It has to work with AOT. Any proposal of workaround is welcome.
Notice that the parent component is under "resolve", so this.route.params.subscribe
will always emit a value straightaway after being called.
Thank you!