diff --git a/components/list/nz-list.component.ts b/components/list/nz-list.component.ts index 60552e2ebda..00ac7475056 100644 --- a/components/list/nz-list.component.ts +++ b/components/list/nz-list.component.ts @@ -17,7 +17,6 @@ import { NzListGrid, ListSize } from './interface'; {{ _header }} - nz-spin: bug
diff --git a/components/spin/nz-spin.component.ts b/components/spin/nz-spin.component.ts index eac7e6b2bd4..9a8ecbf61a5 100644 --- a/components/spin/nz-spin.component.ts +++ b/components/spin/nz-spin.component.ts @@ -28,7 +28,7 @@ import { toBoolean } from '../core/util/convert';
{{ nzTip }}
-
+
@@ -91,20 +91,24 @@ export class NzSpinComponent implements AfterViewInit { return true; } + checkNested(): void { + /** no way to detect empty https://github.com/angular/angular/issues/12530 **/ + if (!this.isEmpty(this._ref.nativeElement)) { + this._nested = true; + this._renderer.setStyle(this._el, 'display', 'block'); + } else { + this._nested = false; + this._renderer.removeStyle(this._el, 'display'); + } + } + constructor(private _elementRef: ElementRef, private _renderer: Renderer2, private zone: NgZone) { this._el = this._elementRef.nativeElement; } ngAfterViewInit(): void { this.zone.onStable.pipe(first()).subscribe(() => { - /** no way to detect empty https://github.com/angular/angular/issues/12530 **/ - if (!this.isEmpty(this._ref.nativeElement)) { - this._nested = true; - this._renderer.setStyle(this._el, 'display', 'block'); - } else { - this._renderer.removeChild(this._ref.nativeElement.parentNode, this._ref.nativeElement); - } + this.checkNested(); }); - } } diff --git a/components/spin/nz-spin.module.ts b/components/spin/nz-spin.module.ts index ffdd94d9a43..a17e7c75785 100644 --- a/components/spin/nz-spin.module.ts +++ b/components/spin/nz-spin.module.ts @@ -1,3 +1,4 @@ +import { ObserversModule } from '@angular/cdk/observers'; import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { NzSpinComponent } from './nz-spin.component'; @@ -5,7 +6,7 @@ import { NzSpinComponent } from './nz-spin.component'; @NgModule({ exports : [ NzSpinComponent ], declarations: [ NzSpinComponent ], - imports : [ CommonModule ] + imports : [ CommonModule, ObserversModule ] }) export class NzSpinModule { }