-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:input-number): support nzPrecisionMode mode (#4185)
* feat(module:input-number): 增加 `nzPrecisionMode` 参数,支持数值精度使用截位方式取值 close #4173 * fix(module:input-number): fix for precision demo * fix(module:input-number): fix for precision unit * refactor(module:input-number): 支持 `nzPrecisionMode` 参数为自定义函数
- Loading branch information
Showing
6 changed files
with
116 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 5 | ||
title: | ||
zh-CN: 精度 | ||
en-US: Precision | ||
--- | ||
|
||
## zh-CN | ||
|
||
指定 value 的精度 | ||
|
||
## en-US | ||
|
||
Set precision of the value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-input-number-precision', | ||
template: ` | ||
<nz-input-number [(ngModel)]="toFixedValue" [nzPrecision]="precision" nzPlaceHolder="toFixed"></nz-input-number> | ||
<nz-input-number | ||
[(ngModel)]="cutValue" | ||
[nzPrecision]="precision" | ||
nzPrecisionMode="cut" | ||
nzPlaceHolder="cut off" | ||
></nz-input-number> | ||
<nz-input-number | ||
[(ngModel)]="customFnValue" | ||
[nzPrecision]="precision" | ||
[nzPrecisionMode]="customPrecisionFn" | ||
nzPlaceHolder="cut off" | ||
></nz-input-number> | ||
`, | ||
styles: [ | ||
` | ||
nz-input-number { | ||
margin-right: 8px; | ||
} | ||
` | ||
] | ||
}) | ||
export class NzDemoInputNumberPrecisionComponent { | ||
toFixedValue = 2.128; | ||
cutValue = 2.128; | ||
customFnValue = 2.128; | ||
precision = 2; | ||
customPrecisionFn(value: number, precision: number): number { | ||
return +Number(value).toFixed(precision + 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters