The specified value cannot be parsed, or is out of range
当我得到我的对象时,我用管道格式化一个数字,但它返回此警告并且不显示该值。如果我删除它,它会显示出来。
这不显示值
<input name="value" [ngModel]="value | number : '1.2-2'"/>
这显示值 <input name="value" [ngModel]="value"/>
TS在这里,我在列表中选择它后通过它的 id 获取我的对象。
ngOnInit(){
this.get();
}
get() {
this.service.get(this.id).subscribe(
(data) => {
this.object = data;
this.name = this.object.name;
this.value = this.object.value;
},
(error) => {
console.log(error);
}
);
}
该值是一个数字,我在控制台中得到它没有任何问题。
最佳答案
<input [value]="units * 600 + 2500 | number" readonly type="text" name="grandtotal"
class="form-control" id="grandtotal" placeholder="Grand Total">
我发现我的解决方案在这里更改或替换 HTML type="text" 中的类型
关于angular - 指定值无法解析,或使用数字管道时超出范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65231352/