Search code examples
angulartypescriptdatepickerangular-material

mat-date-range-input isn't known element [Angular material]


The problem is that I can't use <mat-date-range-input> Material Component because I get an error:

enter image description here

I have a module called "Material module" and there's an import and export of MatNativeDateModule and MatDatepickerModule. This module is imported into module I'm working with.

I can use simple mat-datepicker and it works properly.

Can anybody help me with that?

10.1.2 - version of Material


Solution

  • Are you on an older version of Angular, but on version 10.1.2 of material?

    mat-date-range-input doesn't work on Angular versions lower than 10.0.2. To take advantage of this, you have to update your application, this is pretty straightforward if you are on version 9. I faced the same issue and after updating the range date picker is working.

    For detailed information of how to update go to: https://update.angular.io/.

    These imports also have to be in the app.module.ts

    import {MatDatepickerModule} from '@angular/material/datepicker';
    import {MatNativeDateModule} from '@angular/material/core';
    

    Hope this helps. :)