Ion-dev.js:157 ERROR TypeError: Cannot read property 'updateOn' of null


#1

Does someone know how to solve it? Or what is causing this error? The only thing that I know explain is that this error occurs after return this.http.get<string>(url, { headers: headers }).toPromise(); and before .then(... as usual. This code runs fine for the first time, after close the current Page, and reopening it after, is when it occurs.

VM2550 ion-dev.js:157 ERROR TypeError: Cannot read property 'updateOn' of null
    at VM2554 vendor.js:23961
    at Array.forEach (<anonymous>)
    at syncPendingControls (VM2554 vendor.js:23959)
    at FormGroupDirective.onSubmit (VM2554 vendor.js:28244)
    at Object.eval [as handleEvent] (VM2644 InstrutoresPagamentosCadastroPage.ngfactory.js:544)
    at Object.handleEvent (VM2554 vendor.js:13963)
    at Object.handleEvent (VM2554 vendor.js:14695)
    at dispatchEvent (VM2554 vendor.js:10378)
    at VM2554 vendor.js:11003
    at HTMLFormElement.<anonymous> (VM2554 vendor.js:47482)
(anonymous) @ VM2550 ion-dev.js:157
defaultErrorLogger @ VM2554 vendor.js:1823
ErrorHandler.handleError @ VM2554 vendor.js:1884
IonicErrorHandler.handleError @ VM2554 vendor.js:162090
dispatchEvent @ VM2554 vendor.js:10382
(anonymous) @ VM2554 vendor.js:11003
(anonymous) @ VM2554 vendor.js:47482
t.invokeTask @ VM2553 polyfills.js:3
onInvokeTask @ VM2554 vendor.js:5125
t.invokeTask @ VM2553 polyfills.js:3
r.runTask @ VM2553 polyfills.js:3
e.invokeTask @ VM2553 polyfills.js:3
p @ VM2553 polyfills.js:2
v @ VM2553 polyfills.js:2
Navigated to http://localhost:8100/?

#2

I found what was generating the problem. It occurs when I try to remove dynamically an object from an array linked to form controls created dynamically. The solution was not remove but hide the form control and flag the object array with a “removed” tag.