1
餘米延遲用戶輸入來匹配用戶的打字,當我使用ngZone
服務,它給我的錯誤一樣NgZone未按預期角4
core.es5.js:1084 ERROR TypeError: Cannot read property 'runOutsideAngular' of undefined
at questions-box.component.ts:111
at ZoneDelegate.webpackJsonp.754.ZoneDelegate.invokeTask (zone.js:398)
at Object.onInvokeTask (core.es5.js:4116)
at ZoneDelegate.webpackJsonp.754.ZoneDelegate.invokeTask (zone.js:397)
at Zone.webpackJsonp.754.Zone.runTask (zone.js:165)
at ZoneTask.invoke (zone.js:460)
at timer (zone.js:1540)
我已經正確導入並注入ngZone服務在我的組件
這裏是我的代碼片段
onCategoryChange() {
this.categorySearchTemp = null;
this._timeout = null;
if (this._timeout) {
window.clearTimeout(this._timeout);
}
this._timeout = window.setTimeout(function() {
this._timeout = null;
this.lc.runOutsideAngular(() => {
this.lc.run(() => {
console.log("VALUE", this.categorySearch);
this.getCategory(this.categorySearch);
});
});
}, 1000);
}
爲什麼叫'zone''lc'? – HankCa