diff --git a/components/alert/nz-alert.component.html b/components/alert/nz-alert.component.html
index cfb3a2c88a1..4a242860ae4 100644
--- a/components/alert/nz-alert.component.html
+++ b/components/alert/nz-alert.component.html
@@ -1,4 +1,14 @@
-
+
\ No newline at end of file
diff --git a/components/alert/nz-alert.component.ts b/components/alert/nz-alert.component.ts
index 7f75d4bc37c..5c98242948e 100644
--- a/components/alert/nz-alert.component.ts
+++ b/components/alert/nz-alert.component.ts
@@ -3,14 +3,15 @@ import {
Component,
EventEmitter,
Input,
- OnInit,
+ OnChanges,
Output,
+ SimpleChanges,
TemplateRef,
ViewEncapsulation
} from '@angular/core';
import { fadeAnimation } from '../core/animation/fade-animations';
import { NgClassType } from '../core/types/ng-class';
-import { toBoolean } from '../core/util/convert';
+import { InputBoolean } from '../core/util/convert';
@Component({
selector : 'nz-alert',
@@ -25,108 +26,21 @@ import { toBoolean } from '../core/util/convert';
}`
]
})
-export class NzAlertComponent implements OnInit {
+export class NzAlertComponent implements OnChanges {
display = true;
isTypeSet = false;
isShowIconSet = false;
- prefixClass = 'ant-alert';
- isDescriptionString: boolean;
- isMessageString: boolean;
- isCloseTextString: boolean;
- outerClassMap: NgClassType;
- iconType: string;
- iconTheme: string;
- @Output()
- readonly nzOnClose: EventEmitter
= new EventEmitter();
- @Input()
- nzIconType: NgClassType;
- private _banner = false;
- private _closeable = false;
- private _showIcon = false;
- private _type = 'info';
- private _description: string | TemplateRef;
- private _message: string | TemplateRef;
- private _closeText: string | TemplateRef;
-
- @Input()
- set nzDescription(value: string | TemplateRef) {
- this.isDescriptionString = !(value instanceof TemplateRef);
- this._description = value;
- this.updateOuterClassMap();
- this.updateIconClassMap();
- }
-
- get nzDescription(): string | TemplateRef {
- return this._description;
- }
-
- @Input()
- set nzCloseText(value: string | TemplateRef) {
- this.isCloseTextString = !(value instanceof TemplateRef);
- this._closeText = value;
- }
-
- get nzCloseText(): string | TemplateRef {
- return this._closeText;
- }
-
- @Input()
- set nzMessage(value: string | TemplateRef) {
- this.isMessageString = !(value instanceof TemplateRef);
- this._message = value;
- }
-
- get nzMessage(): string | TemplateRef {
- return this._message;
- }
-
- @Input()
- set nzType(value: string) {
- this._type = value;
- this.isTypeSet = true;
- this.updateOuterClassMap();
- this.updateIconClassMap();
- }
-
- get nzType(): string {
- return this._type;
- }
-
- @Input()
- set nzBanner(value: boolean) {
- this._banner = toBoolean(value);
- if (!this.isTypeSet) {
- this.nzType = 'warning';
- }
- if (!this.isShowIconSet) {
- this.nzShowIcon = true;
- }
- this.updateOuterClassMap();
- }
-
- get nzBanner(): boolean {
- return this._banner;
- }
-
- @Input()
- set nzCloseable(value: boolean) {
- this._closeable = toBoolean(value);
- }
-
- get nzCloseable(): boolean {
- return this._closeable;
- }
-
- @Input()
- set nzShowIcon(value: boolean) {
- this._showIcon = toBoolean(value);
- this.isShowIconSet = true;
- this.updateOuterClassMap();
- }
-
- get nzShowIcon(): boolean {
- return this._showIcon;
- }
+ iconType = 'info-circle';
+ iconTheme = 'fill';
+ @Output() readonly nzOnClose: EventEmitter = new EventEmitter();
+ @Input() @InputBoolean() nzCloseable = false;
+ @Input() @InputBoolean() nzShowIcon = false;
+ @Input() @InputBoolean() nzBanner = false;
+ @Input() nzCloseText: string | TemplateRef;
+ @Input() nzIconType: NgClassType;
+ @Input() nzMessage: string | TemplateRef;
+ @Input() nzDescription: string | TemplateRef;
+ @Input() nzType = 'info';
closeAlert(): void {
this.display = false;
@@ -138,16 +52,6 @@ export class NzAlertComponent implements OnInit {
}
}
- updateOuterClassMap(): void {
- this.outerClassMap = {
- [ `${this.prefixClass}` ] : true,
- [ `${this.prefixClass}-${this.nzType}` ] : true,
- [ `${this.prefixClass}-no-icon` ] : !this.nzShowIcon,
- [ `${this.prefixClass}-banner` ] : this.nzBanner,
- [ `${this.prefixClass}-with-description` ]: !!this.nzDescription
- };
- }
-
updateIconClassMap(): void {
switch (this.nzType) {
case 'error':
@@ -170,8 +74,23 @@ export class NzAlertComponent implements OnInit {
}
}
- ngOnInit(): void {
- this.updateIconClassMap();
- this.updateOuterClassMap();
+ ngOnChanges(changes: SimpleChanges): void {
+ if (changes.nzShowIcon) {
+ this.isShowIconSet = true;
+ }
+ if (changes.nzDescription || changes.nzType) {
+ this.updateIconClassMap();
+ }
+ if (changes.nzType) {
+ this.isTypeSet = true;
+ }
+ if (changes.nzBanner) {
+ if (!this.isTypeSet) {
+ this.nzType = 'warning';
+ }
+ if (!this.isShowIconSet) {
+ this.nzShowIcon = true;
+ }
+ }
}
}
diff --git a/components/alert/nz-alert.module.ts b/components/alert/nz-alert.module.ts
index 652660179e1..02473ff60ae 100644
--- a/components/alert/nz-alert.module.ts
+++ b/components/alert/nz-alert.module.ts
@@ -1,5 +1,6 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
+import { NzAddOnModule } from '../core/addon/addon.module';
import { NzIconModule } from '../icon/nz-icon.module';
import { NzAlertComponent } from './nz-alert.component';
@@ -7,7 +8,7 @@ import { NzAlertComponent } from './nz-alert.component';
@NgModule({
declarations: [ NzAlertComponent ],
exports : [ NzAlertComponent ],
- imports : [ CommonModule, NzIconModule ]
+ imports : [ CommonModule, NzIconModule, NzAddOnModule ]
})
export class NzAlertModule {
}
diff --git a/components/card/nz-card-meta.component.html b/components/card/nz-card-meta.component.html
index b07d8e6452a..976cfb24454 100755
--- a/components/card/nz-card-meta.component.html
+++ b/components/card/nz-card-meta.component.html
@@ -3,15 +3,9 @@