我正在使用p3x-angular-compiler
plugin,并且我的html中有一个引用变量,因此我试图在组件中获取它。
HTML-
<div #scrollMe></div>
ts-
@ViewChild('scrollMe') private chatScrollContainer: ElementRef;
当我在this.chatScrollContainer
中管理ngOnInit
时,我不确定。
答案 0 :(得分:0)
尝试将代码从ngOnInit
移至ngAfterViewInit
答案 1 :(得分:0)
我知道这个线程很旧,但原因是 p3x-angular-compile 创建了一个组件,其中包含一个上下文对象,其中包含您的变量。
您应该在模板变量前加上“上下文”。
{{context.foo}}