我应该安装哪个Angular Material版本以与Angular4兼容? [英] Which Angular Material version should I install to be compatible with Angular4?

查看:71
本文介绍了我应该安装哪个Angular Material版本以与Angular4兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该安装哪个Angular Material版本以与Angular4兼容?

我已经使用以下命令在Angular 4项目的顶部安装angular Material.

  npm install @ angular/materailnpm安装@ angular/cdknpm install @角度/动画 

当我尝试运行该应用程序时,我遇到了以下错误.

 /node_modules/@angular/cdk/observers/typings/observe-content.d.ts(33,22):类型'ElementRef'不是通用的. 

解决方案

让我写出更详细的步骤,以使初学者更轻松.尽管问题仅针对版本4,但答案适用于所有版本.

我使用的最新角材版本9遇到了一些问题,因为我的角材版本为8.所以我必须找到兼容的角材版本.以下是我遵循的步骤:

1-检查package.json文件,并注意Angular模块的主要版本.如下图所示,核心,编译器,通用等版本为8.2.14.主要版本是8.

2-转到

3-因此,对于角度v8.2.24,我发现可比的角度材料版本为8.2.3.而且它没有任何错误.

Which Angular Material version should I install to be compatible with Angular4?

I have used below command to install angular Material on the top of Angular 4 project.

npm install @angular/materail 
npm install @angular/cdk
npm install @angular/animations

While I try to run the app I am getting below error.

/node_modules/@angular/cdk/observers/typings/observe-content.d.ts (33,22): Type 'ElementRef' is not generic.

解决方案

Let me write the steps with more details to make it easier for beginners. Though the question is specific to version 4, the answer is applicable to all versions.

I had faced some issues with latest angular material version 9 as my angular version was 8. So I had to found the compatible version of angular material. Below are the steps I followed:

1- Check the package.json file and notice the major version of angular modules. As shown below- core, compiler, common etc are having version as 8.2.14. Major version is 8.

2- Go to https://material.angular.io/ and on right hand top corner find the material version with same major version (8.2.3 in my case). Refer pic below.

3- Thus for angular v8.2.24, I found compartible angular material verison as 8.2.3. And it working with out any error.

这篇关于我应该安装哪个Angular Material版本以与Angular4兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆