Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell committed Jan 21, 2019
1 parent f17c73e commit c2aaebe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 29 deletions.
4 changes: 2 additions & 2 deletions components/statistic/doc/index.en-US.md
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions components/statistic/doc/index.zh-CN.md
Expand Up @@ -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

Expand Down
31 changes: 13 additions & 18 deletions components/statistic/nz-countdown.component.ts
Expand Up @@ -2,7 +2,9 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
Input, NgZone, OnChanges,
Input,
NgZone,
OnChanges,
OnDestroy,
OnInit, SimpleChanges,
ViewEncapsulation
Expand All @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
}
);
Expand Down
10 changes: 3 additions & 7 deletions 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,
Expand All @@ -25,10 +24,7 @@ export class NzStatisticComponent {
@Input() nzTitle: string | TemplateRef<void>;
@Input() nzValue: NzStatisticValueType;
@Input() nzValueStyle = {};
@Input() nzDecimalSeparator: string = '.';
@Input() nzGroupSeparator: string = ',';
@Input() nzDecimalSeparator = '.';
@Input() nzGroupSeparator = ',';
@Input() nzValueTemplate: TemplateRef<{ $implicit: NzStatisticValueType }>;

constructor(protected cdr: ChangeDetectorRef) {
}
}

0 comments on commit c2aaebe

Please sign in to comment.