diff --git a/components/statistic/doc/index.en-US.md b/components/statistic/doc/index.en-US.md index bc2db60116f..1a353050504 100644 --- a/components/statistic/doc/index.en-US.md +++ b/components/statistic/doc/index.en-US.md @@ -24,8 +24,8 @@ Display statistic number. | `[nzValue]` | Value | `string|number` | - | | `[nzValueStyle]` | Value CSS style | `Object` | - | | `[nzValueTemplate]` | Custom template to render a number | `TemplateRef<{ $implicit: NzStatisticValueType }>` | - | -| `[nzDecimalSeparator]` | Decimal separator | `string` | "." | -| `[nzGroupSeparator]` | Group separator | `string` | "," | +| `[nzDecimalSeparator]` | Decimal separator | `string` | `.` | +| `[nzGroupSeparator]` | Group separator | `string` | `,` | ### nz-countdown diff --git a/components/statistic/doc/index.zh-CN.md b/components/statistic/doc/index.zh-CN.md index 0a381fc5ce6..b8d7e8702b5 100644 --- a/components/statistic/doc/index.zh-CN.md +++ b/components/statistic/doc/index.zh-CN.md @@ -25,8 +25,8 @@ type: Data Display | `[nzValue]` | 数值内容 | `string|number` | - | | `[nzValueStyle]` | 设置数值的样式 | `Object` | - | | `[nzValueTemplate]` | 自定义数值展示 | `TemplateRef<{ $implicit: NzStatisticValueType }>` | - | -| `[nzDecimalSeparator]` | 小数位分隔符 | `string` | "." | -| `[nzGroupSeparator]` | 千位分隔符 | `string` | "," | +| `[nzDecimalSeparator]` | 小数位分隔符 | `string` | `.` | +| `[nzGroupSeparator]` | 千位分隔符 | `string` | `,` | ### nz-countdown diff --git a/components/statistic/nz-countdown.component.ts b/components/statistic/nz-countdown.component.ts index 39c9796a012..8b924677299 100644 --- a/components/statistic/nz-countdown.component.ts +++ b/components/statistic/nz-countdown.component.ts @@ -2,7 +2,9 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, - Input, NgZone, OnChanges, + Input, + NgZone, + OnChanges, OnDestroy, OnInit, SimpleChanges, ViewEncapsulation @@ -27,10 +29,10 @@ export class NzCountdownComponent extends NzStatisticComponent implements OnInit diff: number; displayText = ''; target: number; - updater_: Subscription; + updater_ = new Subscription(); - constructor(protected cdr: ChangeDetectorRef, private ngZone: NgZone) { - super(cdr); + constructor(private cdr: ChangeDetectorRef, private ngZone: NgZone) { + super(); } /** @override */ @@ -62,25 +64,21 @@ export class NzCountdownComponent extends NzStatisticComponent implements OnInit startTimer(): void { // NOTE: let interval triggered outside of zone for performance considerations. this.ngZone.runOutsideAngular(() => { - if (!this.updater_) { - this.updater_ = interval(REFRESH_INTERVAL).subscribe(() => { - this.updateValue(); - this.cdr.detectChanges(); - }); - } + this.stopTimer(); + this.updater_ = interval(REFRESH_INTERVAL).subscribe(() => { + this.updateValue(); + this.cdr.detectChanges(); + }); }); } stopTimer(): void { - if (this.updater_) { - this.updater_.unsubscribe(); - this.updater_ = null; - } + this.updater_.unsubscribe(); + this.updater_ = null; } /** * Update time that should be displayed on the screen. - * @override */ protected updateValue(): void { this.diff = Math.max(this.target - Date.now(), 0); @@ -108,9 +106,6 @@ export class NzCountdownComponent extends NzStatisticComponent implements OnInit return current.replace( new RegExp(`${name}+`, 'g'), (match: string) => { - if (name === 'S') { - console.log(match); - } return padStart(value.toString(), match.length, '0'); } ); diff --git a/components/statistic/nz-statistic.component.ts b/components/statistic/nz-statistic.component.ts index ab6c2edac7a..35ec0276b30 100644 --- a/components/statistic/nz-statistic.component.ts +++ b/components/statistic/nz-statistic.component.ts @@ -1,12 +1,11 @@ import { ChangeDetectionStrategy, - ChangeDetectorRef, Component, Input, TemplateRef, ViewEncapsulation } from '@angular/core'; -import { NzStatisticConfig, NzStatisticValueType } from './nz-statistic-config'; +import { NzStatisticValueType } from './nz-statistic-config'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, @@ -25,10 +24,7 @@ export class NzStatisticComponent { @Input() nzTitle: string | TemplateRef; @Input() nzValue: NzStatisticValueType; @Input() nzValueStyle = {}; - @Input() nzDecimalSeparator: string = '.'; - @Input() nzGroupSeparator: string = ','; + @Input() nzDecimalSeparator = '.'; + @Input() nzGroupSeparator = ','; @Input() nzValueTemplate: TemplateRef<{ $implicit: NzStatisticValueType }>; - - constructor(protected cdr: ChangeDetectorRef) { - } }