do toggle operation onoverlayPanel in.ts

Viewed 1018

I need to do toggle operation on a element :

   <p-overlayPanel #panel>...

I must take it in my .ts code:

    @ViewChild('panel') someInput: ElementRef;
this.someInput.toggle()

and after I don't knwo what I have to do? anyone can help me?

1 Answers

you can get a reference of the overlayPanel component like this

 @ViewChild('panel',{static:true}) panel: OverlayPanel;

then you can call toggle or show method but these method require a browser event or target element to align the panel

 @ViewChild('elm',{static:true}) elm: ElementRef;

then you can call toggle method like this

 ngOnInit(){
   this.panel.toggle(null,this.elm.nativeElement)
 }

demo

Related