I am using the WindowService to open a window and passing in a template for the content. Once the user performs their action within the window, I want to close it.
I tried adding
publicwindow : WindowRef
to my constructor, but this threw an error, 'No provider for WindowRef'
Georgi
Telerik team
commented on 26 Dec 2023, 10:14 AM
Hi Clifford,
Thank you very much for the details provided.
From what I understood from your question, you are currently utilizing the Kendo UI for Angular Window using the Angular Service and are looking for an approach that would allow you to programmatically close the component. Please, correct me if I misunderstood you.
Indeed, you are correct that the developer could use the WindowRef and the built-in close() method in order to close the Window component programmatically:
Hi Clifford,
Thank you very much for the details provided.
From what I understood from your question, you are currently utilizing the Kendo UI for Angular Window using the Angular Service and are looking for an approach that would allow you to programmatically close the component. Please, correct me if I misunderstood you.
Indeed, you are correct that the developer could use the WindowRef and the built-in close() method in order to close the Window component programmatically:
export class AppComponent { constructor(private windowService: WindowService) {} public windowRef: WindowRef; ... public showList(template: TemplateRef<unknown>): void { this.windowRef = this.windowService.open({ title: 'My List', content: template, width: 250, height: 230, }); } public onClick() { this.windowRef.close(); } }
To better illustrate the suggested approach, I am sending you a StackBlitz demo that implements it:
https://stackblitz.com/edit/angular-sjqdlb
I hope this helps. Please, let me know if I am missing out on something.
Regards,Georgi
Progress Telerik