NullInjectorError: No provider for MatSelect! After upgrade to angular material 15

1.5k views Asked by At

I have updated angular project from v14 to v15.0.4 and mat-select throws the error. It was fully working before upgrading.

Angular version : 15.0.4 Angular Material version : 15.0.4

ERROR NullInjectorError: R3InjectorError(TestModule)[MatSelect -> MatSelect -> MatSelect]: NullInjectorError: No provider for MatSelect!

Current still using the legacy-select, imported in material.module.ts and it's imported in app module

import {MatLegacySelectModule as MatSelectModule} from '@angular/material/legacy-select';

imports: [
        MatSelectModule,
    ],
3

There are 3 answers

2
Baptiste Borel On BEST ANSWER

If you still use MatLegacySelectModule and use ngx-mat-select-search dependency, make sure you are in version 6.x.x. (Cf Compatibility part)

1
Rashid Shiralizade On

Try this:

import { MatSelectModule } from '@angular/material/select';
1
Nikhil Patil On

If you are using ngx-mat-select-search then MatLegacySelectModule (@angular/material/legacy-select) of @angular/material@15 is not supported anymore, please use version 6.0.0

you can read it here ngx-mat-select-search - yarn package manager