![](/img/trans.png)
[英]How to trigger local reference in parent component from child component event in 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.