Migration from material angular 5 to material angular 6

Asked

Viewed 130 times

0

I am migrating from angular 5 to 6 and material 5 to 6. The problem is that the second error occurs when climbing the application.

TypeError: Cannot read property 'appendChild' of null
at MatCommonModule.push../node_modules/@angular/material/esm5/core.es5.js.MatCommonModule._checkThemeIsPresent (core.es5.js:141)
at new MatCommonModule (core.es5.js:93)
at _createClass (core.js:8116)
at _createProviderInstance$1 (core.js:8088)
at initNgModule (core.js:8024)
at new NgModuleRef_ (core.js:8747)
at createNgModuleRef (core.js:8736)
at Object.debugCreateNgModuleRef [as createNgModuleRef] (core.js:10561)
at NgModuleFactory_.push../node_modules/@angular/core/fesm5/core.js.NgModuleFactory_.create (core.js:11263)
at core.js:4161

So far I have seen no solution to solve the problem.

1 answer

0

The solution found for this problem is as follows. In the app.module.ts file within providers the following code should be placed:

 {
    provide: MATERIAL_SANITY_CHECKS, 
    useValue: false
 }

This command means that it will not be checked if any material angular theme has been used, so the code will work with external themes without error.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.