Can I change the title on a window created by window service where the content is a component?

0 Answers 76 Views
Window
Noah
Top achievements
Rank 2
Iron
Iron
Iron
Noah asked on 16 Mar 2023, 04:56 PM
I'm creating a window with the window service and setting a title. But then user selection may change and the contents of the window might change. I can get the instance of the component and change its inputs so the content of the window changes, but how do I change the title of the window without closing it and reopening a new window with a different title?
Noah
Top achievements
Rank 2
Iron
Iron
Iron
commented on 16 Mar 2023, 05:16 PM

I figured out how to do it with the titleTemplate field. Is it possible to use the new appearance settings for windows with the angular service? would i use the cssClass property?
Martin Bechev
Telerik team
commented on 21 Mar 2023, 12:30 PM

Hi Noah,

Using a template is the correct approach.

To dynamically change the applied cssClass, use the created Window instance and change the cssClass value like:

public windowRef: WindowRef;
  public openWindow(): void {
    this.windowRef = this.windowService.open({
      title: 'My Window',
   ...
      cssClass: 'redHeader',
    });
  }

  onClick() {
    this.windowRef.window.instance.cssClass = 'greenHeader';
  }

Here is an example:

https://stackblitz.com/edit/angular-8mjsbg

I hope this helps.

Regards,

Martin

No answers yet. Maybe you can help?

Tags
Window
Asked by
Noah
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or