-
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:alert): support nzAction for customizing actions (#7246)
- Loading branch information
1 parent
aeff540
commit eb3b1ba
Showing
7 changed files
with
85 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 7 | ||
title: | ||
zh-CN: 操作 | ||
en-US: Custom action | ||
--- | ||
|
||
## zh-CN | ||
|
||
可以在右上角自定义操作项。 | ||
|
||
## en-US | ||
|
||
Custom action. |
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,54 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-alert-action', | ||
template: ` | ||
<nz-alert nzShowIcon nzType="success" nzMessage="Success Text" [nzAction]="actionTemplate1"></nz-alert> | ||
<ng-template #actionTemplate1> | ||
<button nz-button nzSize="small" nzType="text" (click)="doAction('undo')">Undo</button></ng-template | ||
> | ||
<br /> | ||
<nz-alert | ||
nzShowIcon | ||
nzType="error" | ||
nzMessage="Error Text" | ||
[nzDescription]="descriptionTemplate1" | ||
[nzAction]="actionTemplate2" | ||
></nz-alert> | ||
<ng-template #descriptionTemplate1> | ||
<p>Error Description Error Description Error Description Error Description</p> | ||
</ng-template> | ||
<ng-template #actionTemplate2> | ||
<button nz-button nzSize="small" nzType="default" nzDanger (click)="doAction('detail')">Detail</button> | ||
</ng-template> | ||
<br /> | ||
<nz-alert nzCloseable nzType="warning" nzMessage="Warning Text" [nzAction]="actionTemplate3"></nz-alert> | ||
<ng-template #actionTemplate3> | ||
<button nz-button nzSize="small" nzType="primary" nzGhost (click)="doAction('ignore')">Ignore</button> | ||
</ng-template> | ||
<br /> | ||
<nz-alert | ||
nzShowIcon | ||
nzType="info" | ||
nzMessage="Info Text" | ||
[nzDescription]="descriptionTemplate2" | ||
[nzAction]="actionTemplate4" | ||
></nz-alert> | ||
<ng-template #descriptionTemplate2> | ||
<p>Info Description Info Description Info Description Info Description</p> | ||
</ng-template> | ||
<ng-template #actionTemplate4> | ||
<nz-space nzDirection="vertical"> | ||
<button *nzSpaceItem nz-button nzSize="small" nzType="primary" (click)="doAction('accept')">Accept</button> | ||
<button *nzSpaceItem nz-button nzSize="small" nzType="default" nzDanger (click)="doAction('decline')" | ||
>Decline</button | ||
> | ||
</nz-space> | ||
</ng-template> | ||
` | ||
}) | ||
export class NzDemoAlertActionComponent { | ||
doAction(action: string): void { | ||
console.log(`Do alert's action: ${action}`); | ||
} | ||
} |
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,3 +1,5 @@ | ||
import { NzAlertModule } from 'ng-zorro-antd/alert'; | ||
import { NzButtonModule } from 'ng-zorro-antd/button'; | ||
import { NzSpaceModule } from 'ng-zorro-antd/space'; | ||
|
||
export const moduleList = [ NzAlertModule ]; | ||
export const moduleList = [ NzAlertModule, NzButtonModule, NzSpaceModule ]; |
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