Topic: Cannot read property \\\'unsubscribe\\\' of undefined at MDBFileSelectDirective.ngOnDestroy
deeep580 pro asked 6 years ago
Damian Gemza staff answered 6 years ago
subax911 free commented 6 years ago
I will just send u a pull request since there are bunch of juniors in this MDB company i see..
jadams priority commented 6 years ago
Was seeing the same issue and adding null check to that function works well. If that can be included in the repo that would be great.
Thank you
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Pro
- Premium support: No
- Technology: MDB Angular
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No
Damian Gemza staff commented 6 years ago
Dear deeep580, I tried to reproduce your problem - got app component and second component, and two routes, for app and for second. In second i've got file input. I'm picking with it some files, and then clicking button to route me to app component, and I got no errors. Could you try to make some try catch for this.uploadInput.unsubscribe() ? Or if (this.uploadInput.unsubscribe() !== undefined) ? Maybe this will help you. Best Regards, Damianewgiddings free commented 6 years ago
I am experiencing the same problem: TypeError: Cannot read property 'unsubscribe' of undefined at MDBFileSelectDirective.ngOnDestroy (ng-uikit-pro-standard.es5.js:5366) When I load the component and then change the route this error comes up and prevents the route change. Can you please explain further the solution your provided for this error?ewgiddings free commented 6 years ago
Should there be a null check at ng-uikit-pro-standard.es5.js:5366 to prevent this from happening? It happens on every page I include the 'mdbFileSelect'Damian Gemza staff commented 6 years ago
Dear ewgiddings, I have tried to reproduce your case but without any success. I have 2 routes and File Upload code. After changing routes to a component which holds File Input I have no errors. After changing this route to another again I see no errors. Could you please describe me reproduction steps, or provide me with a reproduction repository? Best Regards, DamianJukic-Sunaric pro commented 6 years ago
I have the same error. It happens when a site has the 'mdbFileSelect' directive and you try to navigate away from it.
hans.pret@gmail.com pro commented 6 years ago
Exactly the same error for me as well. I use the mdbFileSelect directive on one of my pages and when navigating away I get the following error:
TypeError: Cannot read property 'unsubscribe' of undefined
at MDBFileSelectDirective.push../node_modules/ng-uikit-pro-standard/esm5/ng-uikit-pro-standard.es5.js.MDBFileSelectDirective.ngOnDestroy (ng-uikit-pro-standard.es5.js:5647)
at callProviderLifecycles (core.js:9365)
at callElementProvidersLifecycles (core.js:9333)
at callLifecycleHooksChildrenFirst (core.js:9323)
at destroyView (core.js:10385)
at callViewAction (core.js:10511)
at execComponentViewsAction (core.js:10433)
at destroyView (core.js:10384)
at callViewAction (core.js:10511)
at execComponentViewsAction (core.js:10433)
at MDBFileSelectDirective.push../node_modules/ng-uikit-pro-standard/esm5/ng-uikit-pro-standard.es5.js.MDBFileSelectDirective.ngOnDestroy (ng-uikit-pro-standard.es5.js:5647)
at callProviderLifecycles (core.js:9365)
at callElementProvidersLifecycles (core.js:9333)
at callLifecycleHooksChildrenFirst (core.js:9323)
at destroyView (core.js:10385)
at callViewAction (core.js:10511)
at execComponentViewsAction (core.js:10433)
at destroyView (core.js:10384)
at callViewAction (core.js:10511)
at execComponentViewsAction (core.js:10433)
at resolvePromise (zone.js:814)
at resolvePromise (zone.js:771)
at zone.js:873
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:3748)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
at drainMicroTaskQueue (zone.js:595)
at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:500)
at invokeTask (zone.js:1540)
Please have a look at this. There is a lot of complaints about the specific error.
subax911 free commented 6 years ago
Hello everyone, and hello to MDB team aswell, after some digging, i have found solution for your problems. For you guys please navigate to node_modules/ng-uikit-pro-standard/esm5/ng-uikit-pro-standard.es5.js and find this line of code on the picture below, comment what i have commented and write what i did here https://i.gyazo.com/66d135e657131c151d6f521e8b6478fc.png" />
Damian Gemza staff commented 6 years ago
Dear subax911,
Thanks for your participation! We'll take look at this.
Best Regards,
Damian