From 9abfd49f3f59637fa3cea26e50ee0490a61dbf4c Mon Sep 17 00:00:00 2001 From: KenTandrian Date: Sun, 8 Feb 2026 15:27:26 +0700 Subject: [PATCH] fix(ui): change to input fn and remove checker --- libs/ui/src/lib/value/value.component.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libs/ui/src/lib/value/value.component.ts b/libs/ui/src/lib/value/value.component.ts index 22fca776b..d6d99a059 100644 --- a/libs/ui/src/lib/value/value.component.ts +++ b/libs/ui/src/lib/value/value.component.ts @@ -6,7 +6,8 @@ import { ChangeDetectionStrategy, Component, Input, - OnChanges + OnChanges, + input } from '@angular/core'; import { IonIcon } from '@ionic/angular/standalone'; import { isNumber } from 'lodash'; @@ -30,7 +31,6 @@ export class GfValueComponent implements OnChanges { @Input() isPercent = false; @Input() locale: string; @Input() position = ''; - @Input() precision?: number; @Input() size: 'large' | 'medium' | 'small' = 'small'; @Input() subLabel = ''; @Input() unit = ''; @@ -42,8 +42,11 @@ export class GfValueComponent implements OnChanges { public isString = false; public useAbsoluteValue = false; + protected readonly precision = input(); + private get hasPrecision(): boolean { - return this.precision !== undefined && this.precision >= 0; + const precision = this.precision(); + return precision !== undefined && precision >= 0; } public ngOnChanges() { @@ -127,7 +130,7 @@ export class GfValueComponent implements OnChanges { } private getFormatOptions(): Intl.NumberFormatOptions { - const digits = this.hasPrecision ? this.precision : 2; + const digits = this.hasPrecision ? this.precision() : 2; return { maximumFractionDigits: digits, @@ -141,7 +144,6 @@ export class GfValueComponent implements OnChanges { this.isNumber = false; this.isString = false; this.locale = this.locale || getLocale(); - this.precision = this.hasPrecision ? this.precision : undefined; this.useAbsoluteValue = false; } }