How to close a Dialog Window from the parent component when using the WindowService?

1 Answer 44 Views
Window
CJ
Top achievements
Rank 1
CJ asked on 18 Jul 2023, 01:34 PM

I am trying to utilize the WindowService to dynamically create a Window instance from another component. The kendoWindowContainer lives in my app.component.html, but I am using the WindowService to create a window instance in a child component. 

Right now, when our app times out, and a log out is triggered, the window stays opens.

I've tried to use the WindowRef as a constructor parameter, also with the @Optional() decorator, and as a ViewChild, and window is always undefined. Not sure what I am doing wrong when trying to get the WindowRef reference.

1 Answer, 1 is accepted

Sort by
0
Simeon
Telerik team
answered on 20 Jul 2023, 01:25 PM

Hello CJ,

We have received the same question as a private support thread, so I will post the answer here as well, as others could find it helpful:

Using the WindowRef to close the created instance is the correct approach to manually toggle the Window component when it's displayed through a service.

The following example closes the Window from where the component is created (child component):

https://stackblitz.com/edit/angular-fkxyp4

This demo provides the WindowRef from child to root and its closed in the root component (in a setTimeout function just for demonstration purposes):

https://stackblitz.com/edit/angular-fkxyp4-flhvv9

I hope this helps.

Regards,
Simeon
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
Window
Asked by
CJ
Top achievements
Rank 1
Answers by
Simeon
Telerik team
Share this question
or