-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:notification): support for more custom templates (#8046)
- Loading branch information
1 parent
a0b8a0b
commit 9689c42
Showing
7 changed files
with
71 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,3 @@ title: | |
## en-US | ||
|
||
Use template to implement more complex interactions. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,28 @@ | ||
import { Component, TemplateRef } from '@angular/core'; | ||
import { Component, TemplateRef, ViewChild } from '@angular/core'; | ||
|
||
import { NzNotificationService } from 'ng-zorro-antd/notification'; | ||
import { NzNotificationComponent, NzNotificationService } from 'ng-zorro-antd/notification'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-notification-with-btn', | ||
template: ` | ||
<ng-template #template let-notification> | ||
<div class="ant-notification-notice-content"> | ||
<div> | ||
<div class="ant-notification-notice-message">Notification Title</div> | ||
<div class="ant-notification-notice-description"> | ||
A function will be be called after the notification is closed (automatically after the "duration" time of | ||
manually). | ||
</div> | ||
<span class="ant-notification-notice-btn"> | ||
<button nz-button nzType="primary" nzSize="small" (click)="notification.close()"> | ||
<span>Confirm</span> | ||
</button> | ||
</span> | ||
</div> | ||
</div> | ||
<ng-template #notificationBtnTpl let-notification> | ||
<button nz-button nzType="primary" nzSize="small" (click)="notification.close()">Confirm</button> | ||
</ng-template> | ||
<button nz-button [nzType]="'primary'" (click)="createBasicNotification(template)"> | ||
Open the notification box | ||
</button> | ||
<button nz-button [nzType]="'primary'" (click)="openNotification()"> Open the notification box </button> | ||
` | ||
}) | ||
export class NzDemoNotificationWithBtnComponent { | ||
@ViewChild('notificationBtnTpl', { static: true }) btnTemplate!: TemplateRef<{ $implicit: NzNotificationComponent }>; | ||
constructor(private notification: NzNotificationService) {} | ||
|
||
createBasicNotification(template: TemplateRef<{}>): void { | ||
this.notification.template(template); | ||
openNotification(): void { | ||
this.notification.blank( | ||
'Notification Title', | ||
'A function will be be called after the notification is closed (automatically after the "duration" time of manually).', | ||
{ | ||
nzButton: this.btnTemplate | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters