Angular父子组件通信

时间:2019-12-04 18:21:29

标签: angular-components

假设我有一个带有选择器的组件“ abc”:

'app-abc'

和模板:

<span #test>Test</span>

在另一个html的某个地方,我可以这样实现该组件:

<app-abc></app-abc>

在abc.ts文件可以处理的代码上方是否可以添加任何内容? 我尝试了id,class或只是一个属性。使用以下代码时,进入abc.ts文件什么都没有:

@ViewChild('test', {static: false}) span: ElementRef;
ngAfterViewInit() {
  console.log(this.span); // No extra parameters from the implementation code.
}

0 个答案:

没有答案