diff --git a/components/list/nz-list.component.ts b/components/list/nz-list.component.ts index 2ff7c3b2b80..5dd04b899b8 100644 --- a/components/list/nz-list.component.ts +++ b/components/list/nz-list.component.ts @@ -1,4 +1,3 @@ -// tslint:disable: no-any import { ChangeDetectionStrategy, ChangeDetectorRef, @@ -6,12 +5,11 @@ import { ElementRef, Input, OnChanges, - SimpleChanges, TemplateRef } from '@angular/core'; import { NzUpdateHostClassService } from '../core/services/update-host-class.service'; -import { toBoolean } from '../core/util/convert'; +import { InputBoolean } from '../core/util/convert'; import { ListSize, NzListGrid } from './interface'; @@ -32,19 +30,11 @@ import { ListSize, NzListGrid } from './interface'; ` ] }) export class NzListComponent implements OnChanges { - // region: fields + // #region fields + // tslint:disable-next-line:no-any @Input() nzDataSource: any[] = []; - private _bordered = false; - - @Input() - set nzBordered(value: boolean) { - this._bordered = toBoolean(value); - } - - get nzBordered(): boolean { - return this._bordered; - } + @Input() @InputBoolean() nzBordered = false; @Input() nzGrid: NzListGrid; @@ -84,36 +74,19 @@ export class NzListComponent implements OnChanges { @Input() nzRenderItem: TemplateRef; - private _loading = false; - - @Input() - set nzLoading(value: boolean) { - this._loading = toBoolean(value); - } - - get nzLoading(): boolean { - return this._loading; - } + @Input() @InputBoolean() nzLoading = false; @Input() nzLoadMore: TemplateRef; + @Input() nzPagination: TemplateRef; @Input() nzSize: ListSize = 'default'; - private _split = true; - - @Input() - set nzSplit(value: boolean) { - this._split = toBoolean(value); - } - - get nzSplit(): boolean { - return this._split; - } + @Input() @InputBoolean() nzSplit = true; - // endregion + // #endregion - // region: styles + // #region styles private prefixCls = 'ant-list'; @@ -130,16 +103,16 @@ export class NzListComponent implements OnChanges { [ `${this.prefixCls}-something-after-last-item` ]: !!(this.nzLoadMore || this.nzPagination || this._isFooter) }; this.updateHostClassService.updateHostClass(this.el.nativeElement, classMap); - - this.cd.detectChanges(); } - // endregion + // #endregion constructor(private el: ElementRef, private cd: ChangeDetectorRef, private updateHostClassService: NzUpdateHostClassService) { } - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { this._setClassMap(); + // Delayed detection refresh limited by nz-spin, issues [#11280](https://github.com/angular/material2/issues/11280) + setTimeout(() => this.cd.detectChanges()); } }