键值与从api获取的数据不同

我有以下代码

 ngOnInit() {

    this.service.getDetails(param).then(res => {
      // console.log(res);
      this.details= res;
      this.dataDiffer = this.differs.find(this.details).create();
    });

  }

及以下代码

ngDoCheck() {
    console.log(this.dataDiffer);
    if (this.dataDiffer) {
      const changes = this.dataDiffer.diff(this.details);
      console.log(changes)
      if (changes) {
        this.dataChanged(changes);
      }
    }
  }

我面临的 ngDoCheck 问题是在从api获取详细信息之前执行的(在完成ngOnInit()之前

我也尝试了ngAfterViewInit,类似的事情发生了,

并且由于 details 不可用,因此下面的代码引发错误,

const changes = this.dataDiffer.diff(this.details);
  

找不到其他支持对象“未定义”       在KeyValueDiffers.find

解决方法,

请帮助, 谢谢

zgkejizh 回答:键值与从api获取的数据不同

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2995625.html

大家都在问