Home > Mobile >  can angular v15 work without material migration?
can angular v15 work without material migration?

Time:01-03

Could someone explain to me please, when you do angular upgrade to v15 from v14 is the material migration mandatory? Because the angular upgrade guide tells that you can use old(v14) material modules implementations by simply using legacy modules?

https://rc.material.angular.io/guide/mdc-migration ,,The old implementation of each new component is now deprecated, but still available from a "legacy" import. For example, you can import the old mat-button implementation can be used by importing the legacy button module.".

I upgraded the angular and material to v15, but it seems that the legacy modules are not working at all, all of the user interface is broken?

CodePudding user response:

Can you give more informations? Normaly it should migrate automatically your modules to a working but deprecated module.

Example:

import { MatLegacyButtonModule as MatButtonModule } from '@angular/material/legacy-button';

Did you try to remove-reinstall your node modules?

CodePudding user response:

You have to update Angular Material because Angular Material have peer dependencies on Angular.

So if you use Angular Material 14, you have to use Anguar 14. Same for 15.

If you use Angular 15, and Angular Material 14, then the peer dependencies are not met.

And it does not work anymore because in v15 Angular Material does NOT include the typography for components. You have to add it yourself.

If you use a custom theme :

@use '@angular/material' as mat;

$my-primary: mat.define-palette(mat.$indigo-palette, 500);
$my-accent: mat.define-palette(mat.$pink-palette, A200, A100, A400);

$my-warn: mat.define-palette(mat.$red-palette);

$my-theme: mat.define-light-theme((
 color: (
   primary: $my-primary,
   accent: $my-accent,
   warn: $my-warn,
 ),
 typography: mat.define-typography-config(), // <-- THIS LINE
 density: 0,
));

Follow their guide to make it work.

  • Related