我正在尝试修改数字文本框的值,但在更新它时会创建一个永无止境的循环。 模型绑定应仅更新一次
以下组件
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `<kendo-numerictextbox
[spinners]="showButtons"
[restrictDecimals]="true"
[round]="false"
[decimals]="decimals"
[format]="c2"
[ngModel]="value"
(ngModelChange)="onValueChange($event)"></kendo-numerictextbox> `
})
export class AppComponent {
public showButtons: boolean = false;
public format: string;
public decimals: number = 2;
public value: number = 0;
onValueChange(value: string) {
this.value = value + ' USD';
alert(value);
}
}
附 : http://plnkr.co/edit/kjl7e1wrFJGmpKa008cT
请注意,该组件仅适用于数字,并且您传递的值无效。