首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >手动刷新页面以查看组合中的更改

手动刷新页面以查看组合中的更改
EN

Stack Overflow用户
提问于 2019-05-06 23:11:47
回答 1查看 673关注 0票数 0

在我的Range7应用程序中,我有一些组件,所有的数据都来自于我在ngOnInit中调用的API。到目前为止,CRUD运行良好,我正在获得结果,但我面临的唯一问题是每次必须手动刷新页面才能在HTML中看到结果。

component.ts

代码语言:javascript
复制
export class Component implements OnInit {
    public product: Product[];
   constructor(private productService: ProductService){}
    ngOnInit(){
        this.productService.getProducts().subscribe(result =>{
            this.product=result;
            console.log(result);
         });
}

component.html

代码语言:javascript
复制
<dx-data-grid
[dataSource]="product">
<dxi-column dataField="Category " cellTemplate="catTpl"> </dxi-column>
<div *dxTemplate="let t of 'catTpl'">
<span>{{ t.data.categoryId}}</span>
</div>
</dx-data-grid>
EN

回答 1

Stack Overflow用户

发布于 2019-05-06 23:57:35

如果您正在使用devextreme (我猜是从dx-data-grid HTML元素中),请尝试

代码语言:javascript
复制
import { ViewChild } from '@angular/core';
import { DxDataGridComponent } from 'devextreme-angular/ui/data-grid';

export class Component implements OnInit {
  @ViewChild(DxDataGridComponent) grid: DxDataGridComponent;
  // more code
  this.productService.getProducts().subscribe(result =>{
        this.product=result;
        console.log(result);
        this.grid.instance.refresh();
  });
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56013455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档