问题
I am using a beta 8 of Angular Material in my project. It was never been updated since then. Now that v5 is available, we'd like to do so. What things should I consider while doing so? Any information or pointer to it would be really helpful.
Thanks!
回答1:
What you have to do is the following:
- Since
MaterialModulehas been removed, you have to import the modules required for your application separately to either another module (such asMyMaterialModuleand making sure that it is afterBrowserModule), aconst, or adding the modules individually afterBrowserModule. For more info, visit the docs. The
mdselectors have been removed and replaced withmat(as well as classes). To update, installmaterial-prefix-updaterfromnpm:npm i -g angular-material-prefix-updaterAfter npm has installed it globally, run this command on your app's root directory (where the
-pparameter is the app'stsconfig.json):mat-switcher -p src/app/tsconfig.json # Or wherever tsconfig.json isFor more info, visit the source code or use the
--helpparameter.Note: You no longer need to specify
MATERIAL_COMPATIBILITY_MODE.
来源:https://stackoverflow.com/questions/47725503/upgrading-to-angular-material-5