Issue
I used the mat datepicker but its style is not rendering in the web page
I tried add the styling to the styles.less
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
And import the MatNativeDateModule, MatFormFieldModule, MatInputModule in the app.module.ts
import { MatNativeDateModule, MatFormFieldModule, MatInputModule } from "@angular/material";
and
npm i @angular/cdk
and
ng add @angular/material
this is my code:
<input matInput [matDatepicker]="picker">
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker>
</mat-datepicker>
Solution
You should not only import the modules in your app.module.ts
file, but also add them to your imports array of your module definition. You also did not yet import MatDatepickerModule
so you should add this as well:
@NgModule({
imports: [
BrowserModule,
FormsModule,
MatNativeDateModule,
MatDatepickerModule,
MatFormFieldModule,
MatInputModule
],
...
Answered By - Fabian Strathaus
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.