Q)爲什麼我的數據中的更改沒有在UI上顯示,例如項目列表,但只要我與UI交互,它們就會奇蹟般地出現?Ionic 2:數據模型中的更改未在UI中更新,直到與UI交互爲止
例如,如果我得到一個綁定到一個列表中的一些數據,然後更新該名單,像這樣:
this._LocalStorageService.getClients().then(
(data) => {
this.clients = (data.res.rows.length == 1) ? <Client[]>JSON.parse(data.res.rows.item(0).clients) : [];
this.showNoDataPresent = (this.clients.length == 0);
},
(error) => {
this._LogService.error(JSON.stringify(error.err));
}
);
的clients
列表不顯示在用戶界面,直到我與互動該應用程序,例如點擊菜單按鈕或聚焦搜索欄。
我也有類似的問題,這個問題是我在那裏執行請求。我的建議是爲任何需要更新視圖的異步調用避免使用'ngOnInit','onPageWillEnter'和'onPageLoaded'。我不得不使用'onPageDidEnter()'在有載異步調用之後使視圖更新。 –
謝謝,但這正是「onPageWillEnter」和「ngOnInit」的意思!這個錯誤被證實與角度2中的無聲故障有關。我現在使用'onPageWillEnter' /'ngOnInit'完全沒有問題,因此如果您有任何其他問題,您可能需要重新訪問它們。乾杯。 – Dave