Angular Material in Ionic 6

I’m trying to use angular material in ionic 6, but when I do the command ng add @angular/material, don’t work.
Why? How can i make it work?

Hi @frame88,

I have figured it out. You must explicitly install @angular/animations first (I have used version @14.2.10). Then you can install @angular/material with version @14.2.7.

If you don’t install @angular/animations it said:

npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"15.1.2" from @angular/animations@15.1.2
npm ERR! node_modules/@angular/animations
npm ERR!   peer @angular/animations@"^14.0.0 || ^15.0.0" from @angular/material@14.2.7

Don’t know why it referenced @angular/core with version @15.1.2

I hope this helps.


RN I’m getting the feeling you should not do it at all :frowning:
I currently have trouble with Ionic 6 and ngOnInit.

Ionic (6?) seems to discourage using Angular lifecycle Events like ngOnInit in favor of sth. like ionViewWillEnter:

My current problem is when navigating back to a route with a mat-stepper the stepper is where it was before.
I guess Material uses Angular lifecycle hooks.
And I guess it uses it everywhere.
That would make them incompatible? O.o