Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

do toggle operation onoverlayPanel in.ts

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?

like image 837
poopp Avatar asked Jun 10 '26 01:06

poopp


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 🚀

like image 157
Muhammed Albarmavi Avatar answered Jun 11 '26 15:06

Muhammed Albarmavi