ng-ytl-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
83 lines (69 loc) • 2.06 kB
text/typescript
import {
AfterContentInit,
Component,
ElementRef,
HostBinding,
Input,
Renderer2,
ViewChild,
ViewEncapsulation,
} from '@angular/core';
import { toBoolean } from '../util/convert';
export class NzSpinComponent implements AfterContentInit {
private _spinning = true;
_tip: string;
set nzTip(value: string) {
this._tip = value || '加载中...';
}
get nzTip(): string {
return this._tip;
}
set nzSpinning(value: boolean) {
this._spinning = toBoolean(value);
}
get nzSpinning(): boolean {
return this._spinning;
}
_ref: ElementRef;
get isNested(): boolean {
return this.nzSpinning && (this._ref.nativeElement.childNodes.length !== 0);
}
_el: HTMLElement;
_size: string;
// TODO: cannot be literal type since the getter & setter have different value, why that?
set nzSize(value: string) {
this._size = { large: 'lg', small: 'sm' }[ value ];
}
get nzSize(): string {
return this._size;
}
constructor(private _elementRef: ElementRef, private _renderer: Renderer2) {
this._el = this._elementRef.nativeElement;
}
ngAfterContentInit(): void {
if (this._ref.nativeElement.children.length !== 0) {
this._renderer.setStyle(this._el, 'display', 'block');
}
}
}