Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 错误:InvalidPipeArgument:';undefined不是一个数字';对于管道';分母管';_Angular_Typescript_Pipe - Fatal编程技术网

Angular 错误:InvalidPipeArgument:';undefined不是一个数字';对于管道';分母管';

Angular 错误:InvalidPipeArgument:';undefined不是一个数字';对于管道';分母管';,angular,typescript,pipe,Angular,Typescript,Pipe,我有以下意见: 当把光标放在输入上时,我在输入中得到一个未定义的值 这是我的TS: ngOnInit() { this.form = this.createForm(); this.keys.split(',').forEach(item => { set(this.data, item, null); }); 这是我的烟斗: transform(value: number | string, fractionSize?: number): stri

我有以下意见:

当把光标放在输入上时,我在输入中得到一个未定义的值

这是我的TS:

ngOnInit() {
    this.form = this.createForm();
    this.keys.split(',').forEach(item => {
      set(this.data, item, null);
    });
这是我的烟斗:

transform(value: number | string, fractionSize?: number): string {
      const numberValue = transformToNumber(value, this.profile.getCurrentProfile());
    let retNumber = Number(numberValue);
      return this.decimalPipe.transform(retNumber,  this.profile.getDigitsInfo(), this.profile.getLocale());
  }
怎么了


角度版本:7.3.9

您应该首先声明数据。例如:

...
public data: object = {}
...

constructor() {
    this.form = this.createForm();
    this.keys.split(',').forEach(item => {
        set(this.data, item, null);
    });
    this.data = { ...this.data };
}
请注意不要创建对数据对象的新引用。 Angular查找引用更改,因此创建新引用非常重要

html:



似乎是您的数据?.id未定义,无法转换为数字或字符串。您的第二个管道参数是可选的,因此,我认为这被忽略了(没有问题);键=
肋骨,帐户类型,id
;this.keys.split(',).forEach(item=>{set(this.data,item,null);});你能说说什么是
set()
方法吗?set是lodash的一种方法。也许可以尝试使用(change)函数而不是值管道。问题是,如果值(data.id)未定义,我想添加一个测试,它将不会显示在输入中。我该怎么做?未定义的值将不会显示。。。你能解释一下你想要什么样的结果吗?
<input class="number " type= "text"  pInputText [readonly]="" formControlName="id" [required]="" plmNumberFormatter [value]="data.id | numberPipe" />