问题描述
我在我的项目中使用的是Angular Material beta 8.此后从未更新过.现在v5可用了,我们想这样做.这样做时我应该考虑哪些事项?任何信息或指向它的方法都会很有帮助.
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.
谢谢!
推荐答案
您需要执行的操作如下:
What you have to do is the following:
- 由于已删除
MaterialModule
,因此必须将应用程序所需的模块分别导入到另一个模块(例如MyMaterialModule
,并确保它在BrowserModule
之后),const
或在BrowserModule
之后分别添加模块.有关更多信息,请访问文档. -
md
选择器已被删除,并由mat
(以及类)替换.要更新,请从npm
安装material-prefix-updater
:
- Since
MaterialModule
has been removed, you have to import the modules required for your application separately to either another module (such asMyMaterialModule
and making sure that it is afterBrowserModule
), aconst
, or adding the modules individually afterBrowserModule
. For more info, visit the docs. The
md
selectors have been removed and replaced withmat
(as well as classes). To update, installmaterial-prefix-updater
fromnpm
:
npm i -g angular-material-prefix-updater
在npm全局安装后,在应用程序的根目录(其中-p
参数是应用程序的tsconfig.json
)上运行此命令:
After npm has installed it globally, run this command on your app's root directory (where the -p
parameter is the app's tsconfig.json
):
mat-switcher -p src/app/tsconfig.json # Or wherever tsconfig.json is
有关更多信息,请访问源代码或使用--help
参数.
For more info, visit the source code or use the --help
parameter.
注意:您不再需要指定MATERIAL_COMPATIBILITY_MODE
.
这篇关于升级到角材料5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!