From a6500c8868df348d9343a5ad077e35f4f2745901 Mon Sep 17 00:00:00 2001 From: vthinkxie Date: Sat, 22 Jun 2019 11:26:35 +0800 Subject: [PATCH] feat(module:input-number): support nzId --- components/input-number/doc/index.en-US.md | 3 ++ components/input-number/doc/index.zh-CN.md | 3 ++ .../nz-input-number.component.html | 43 ++++++++++--------- .../input-number/nz-input-number.component.ts | 1 + 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/components/input-number/doc/index.en-US.md b/components/input-number/doc/index.en-US.md index b3a80dda0d..51faec1038 100755 --- a/components/input-number/doc/index.en-US.md +++ b/components/input-number/doc/index.en-US.md @@ -24,6 +24,8 @@ import { NzInputNumberModule } from 'ng-zorro-antd'; ### nz-input-number +The value entered in `nz-input-number` will not be verified at the time of input, but will be fed back to `[ngModel]` and `(ngModelChange)` at a specific timing (Enter key, up and down keys, blur, etc.), otherwise input data such as `-0.12` or `1e10`, the `ngModel` will always be `undefined`. + | property | description | type | default | | -------- | ----------- | ---- | ------- | | `[ngModel]` | current value, double binding | `number|string` | `string` | - | @@ -37,6 +39,7 @@ import { NzInputNumberModule } from 'ng-zorro-antd'; | `[nzSize]` | width of input box | `'large'|'small'|'default'` | `'default'` | | `[nzStep]` | The number to which the current value is increased or decreased. It can be an integer or decimal. | `number|string` | `1` | | `[nzPlaceHolder]` | Placeholder of select | `string` | - | +| `[nzId]` | input id attribute inside the component| `string` | - | | `(ngModelChange)` | The callback triggered when the value is changed | `EventEmitter` | - | | `(nzFocus)` | focus callback | `EventEmitter` | - | | `(nzBlur)` | blur callback | `EventEmitter` | - | diff --git a/components/input-number/doc/index.zh-CN.md b/components/input-number/doc/index.zh-CN.md index a24d601d6c..43ac0c0b86 100755 --- a/components/input-number/doc/index.zh-CN.md +++ b/components/input-number/doc/index.zh-CN.md @@ -27,6 +27,8 @@ import { NzInputNumberModule } from 'ng-zorro-antd'; ### nz-input-number +在 `nz-input-number` 中输入的数值不会在输入时进行校验,而是在特定时机(回车键,上下键,失去焦点等)时才会校验后反馈到 `[ngModel]` 和 `(ngModelChange)` 中,否则输入 `-0.12` 或者 `1e10` 这种类型数据时,双向绑定的数据会永远是 `undefined` + | 成员 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | `[ngModel]` | 当前值,可双向绑定 | `number|string` | `string` | - | @@ -40,6 +42,7 @@ import { NzInputNumberModule } from 'ng-zorro-antd'; | `[nzSize]` | 输入框大小 | `'large'|'small'|'default'` | `'default'` | | `[nzStep]` | 每次改变步数,可以为小数 | `number|string` | `1` | | `[nzPlaceHolder]` | 选择框默认文字 | `string` | - | +| `[nzId]` | 组件内部 input 的 id 值 | `string` | - | | `(ngModelChange)` | 数值改变时回调 | `EventEmitter` | - | | `(nzFocus)` | focus时回调 | `EventEmitter` | - | | `(nzBlur)` | blur时回调 | `EventEmitter` | - | diff --git a/components/input-number/nz-input-number.component.html b/components/input-number/nz-input-number.component.html index 1377971bf5..1cdc9c6648 100644 --- a/components/input-number/nz-input-number.component.html +++ b/components/input-number/nz-input-number.component.html @@ -1,32 +1,33 @@
+ class="ant-input-number-handler ant-input-number-handler-up" + (mousedown)="up($event)" + (mouseup)="stop()" + (mouseleave)="stop()" + [class.ant-input-number-handler-up-disabled]="disabledUp"> + class="ant-input-number-handler ant-input-number-handler-down" + (mousedown)="down($event)" + (mouseup)="stop()" + (mouseleave)="stop()" + [class.ant-input-number-handler-down-disabled]="disabledDown">
+ autocomplete="off" + class="ant-input-number-input" + [attr.id]="nzId" + [disabled]="nzDisabled" + [attr.min]="nzMin" + [attr.max]="nzMax" + [placeholder]="nzPlaceHolder" + [attr.step]="nzStep" + (keydown)="onKeyDown($event)" + (keyup)="onKeyUp()" + [ngModel]="displayValue" + (ngModelChange)="onModelChange($event)">
\ No newline at end of file diff --git a/components/input-number/nz-input-number.component.ts b/components/input-number/nz-input-number.component.ts index 5421115beb..8645a93147 100644 --- a/components/input-number/nz-input-number.component.ts +++ b/components/input-number/nz-input-number.component.ts @@ -70,6 +70,7 @@ export class NzInputNumberComponent implements ControlValueAccessor, AfterViewIn @Input() nzPrecision: number; @Input() nzPlaceHolder = ''; @Input() nzStep = 1; + @Input() nzId: string; @Input() @InputBoolean() nzDisabled = false; @Input() @InputBoolean() nzAutoFocus = false; @Input() nzFormatter: (value: number) => string | number = value => value;