手动刷新页面以查看组件的变化

时间:2019-05-06 23:11:48

标签: angular

在我的angular 7应用程序中,我具有一些组件,所有数据均来自我在ngOnInit中调用的API。到目前为止,CRUD正常运行,并且得到了结果,但是我面临的唯一问题是每次必须手动刷新页面才能在HTML中查看结果时,我所面临的唯一问题。

component.ts

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

<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>

1 个答案:

答案 0 :(得分:0)

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

@echo off

:Weapon
set /a weapon=%random% * 3 / 32768 + 1
if %weapon% == 1 set weapon=Battleaxe
if %weapon% == 2 set weapon=Sword
if %weapon% == 3 set weapon=Mace

:Enchant
set /a enchantmenttype=%random% * 2 / 32768 + 1
if %enchantmenttype% ==1 goto Enchant1
if %enchantmenttype% ==2 goto Enchant2

:Enchant1
set /a enchantment=%random% * 3 / 32768 + 1
if %enchantment% == 1 set enchantment=Flaming
if %enchantment% == 2 set enchantment=Holy
if %enchantment% == 3 set enchantment=Frozen
set "EW=%enchantment% %weapon%"
goto EW

:Enchant2
set /a enchantment=%random% * 3 / 32768 + 1
if %enchantment% == 1 set "enchantment=the Fire Spirit"
if %enchantment% == 2 set "enchantment=the Frozen Spirit"
if %enchantment% == 3 set "enchantment=the Phantom Spirit"
set "EW=%weapon% of %enchantment%"
goto EW

:EW
echo %EW%
pause >nul
goto Weapon