-
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 nzData as context in template
close #2755
- Loading branch information
Wendell
committed
Feb 19, 2019
1 parent
abbf3b1
commit 0734cd1
Showing
7 changed files
with
70 additions
and
9 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
order: 8 | ||
title: | ||
zh-CN: 使用模板 | ||
en-US: Use a template | ||
--- | ||
|
||
## zh-CN | ||
|
||
通过模板来实现更加复杂的效果和交互。 | ||
|
||
## 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Component, TemplateRef, ViewChild } from '@angular/core'; | ||
import { NzNotificationService } from 'ng-zorro-antd'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-notification-template', | ||
template: ` | ||
<button nz-button [nzType]="'primary'" (click)="ninja()">Open the notification box</button> | ||
<ng-template let-fruit="data"> | ||
It's a <nz-tag [nzColor]="fruit.color">{{ fruit.name }}</nz-tag> | ||
<button nz-button nzType="small">Cut It!</button> | ||
</ng-template> | ||
`, | ||
styles : [ | ||
`button { | ||
margin-top: 8px; | ||
}` | ||
] | ||
}) | ||
export class NzDemoNotificationTemplateComponent { | ||
@ViewChild(TemplateRef) template: TemplateRef<{}>; | ||
|
||
ninja(): void { | ||
const fruits = [ | ||
{ name: 'Apple', color: 'red' }, | ||
{ name: 'Orange', color: 'orange' }, | ||
{ name: 'Watermelon', color: 'green' } | ||
]; | ||
|
||
fruits.forEach(fruit => { | ||
this.notificationService.template(this.template, { nzData: fruit }); | ||
}); | ||
} | ||
|
||
constructor(private notificationService: NzNotificationService) { | ||
} | ||
} |
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