This is a migrated thread and some comments may be shown as answers.

Updating a notification

1 Answer 131 Views
Notification
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 14 Aug 2019, 01:59 PM
Is there anyway to access an existing notification so it can be updated? The scenario I am working with is a countdown to logging out.

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 16 Aug 2019, 09:06 AM
Hi Paul,

To access the content of an existing notification we use template which allows us to customize the notification. We need to pass a TemplateRef to the content property of the NotificationSettings:

template: `
    <ng-template #template>
        <p> Some text here </p>
    </ng-template>
 
    <button class="k-button" (click)="show()">Show</button>
  `
})
export class AppComponent {
  @ViewChild('template', { read: TemplateRef }) public notificationTemplate: TemplateRef<any>;
 
  constructor(private notificationService: NotificationService) { }
 
  public show(): void {
    if (this.isShow != 0) {
      this.notificationService.show({
        content: this.notificationTemplate,
        position: { horizontal: 'right', vertical: 'top' },
         ...
      });
    }
  }
}

I prepared an example to demonstrates the template in action by implementing a countdown:

https://stackblitz.com/edit/angular-6zhep9?file=app/app.component.ts

I hope this helps. Let me know if any further assistance is required for Kendo UI for Angular.

Regards,
Martin
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Notification
Asked by
Paul
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or