簡體   English   中英

如何從Angular 2中的父組件觸發子組件中的本地引用

[英]How to trigger local reference in child component from parent component in Angular 2

在我有的情況下

父組件:

  <button (click)="panel.toggle($event)">Click</div>

孩子:

   <child></child> which has the reference

     and includes

     <p-overlayPanel  #panel>
       Content
    </p-overlayPanel>

如何從父組件訪問#panel 引用? PrimeNG 覆蓋面板

 @ViewChild(‘panel’) panel: ParentComponent

使用@ViewChild()裝飾器,您可以從父組件訪問子組件

您可以切換: this.panel.show(); this.panel.hide();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM