如何在Angular 2中強制組件的重新渲染?為了與Redux一起進行調試,我想強制組件重新呈現其視圖,這可能嗎?
4 回答

郎朗坤
TA貢獻1921條經驗 獲得超9個贊
ChangeDetectorRef方法
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
export class MyComponent {
constructor(private cdr: ChangeDetectorRef) { }
selected(item: any) {
if (item == 'Department')
this.isDepartment = true;
else
this.isDepartment = false;
this.cdr.detectChanges();
}
}
- 4 回答
- 0 關注
- 3293 瀏覽
添加回答
舉報
0/150
提交
取消