【问题标题】:ng2-smart-table not rer-endering after source changeng2-smart-table 在源更改后不重新渲染
【发布时间】:2017-11-21 05:57:01
【问题描述】:

这可能看起来很常见。但是我这几天都面临这个问题。

我正在使用 ng2-smart-table,它正在使用来自 REST API 的数据进行更新。异步调用后首次加载数据。

但是,在不同组件中的事件之后,在发出之后,我可以看到调用了相同的方法,正在为同一个表获取数据,但是这次没有用新数据重新渲染表。任何人都可以有帮助吗?

我使用如下代码 sn-p 来重新加载数据表。

private getQuestions()
  {
    this._questionService.getAll().subscribe(data => 

      {
      //this.data = data;
      //this.source.load(slice();
      this.data.load(data);
      this.data.reset();
      //this.data.update()
      this.data.refresh();
      console.log('Data length:'+this.data.count());
      this.cd.markForCheck();
      },
      error=> console.log("Error: "+error));
  }

【问题讨论】:

    标签: angular ng2-smart-table


    【解决方案1】:

    每次加载数据时都必须清除源。很可能它正在被附加。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-08
      • 2017-11-23
      相关资源
      最近更新 更多