Angular Material Date-Picker无法正常工作 [英] Angular Material Date-Picker is not working properly
问题描述
我正在尝试使用下面提到的Angular Material datepicker获取日期,
I am trying to get date using Angular Material datepicker as mentioned bellow,
在html
<mat-form-field>
<mat-label>Custom calendar color</mat-label>
<input matInput [matDatepicker]="picker2">
<mat-datepicker-toggle matSuffix [for]="picker2"></mat-datepicker-toggle>
<mat-datepicker #picker2 color="primary"></mat-datepicker>
</mat-form-field>
在app.module.ts
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatNativeDateModule } from '@angular/material';
imports: [
MatDatepickerModule,
MatNativeDateModule
],
在我的package.json
依赖项":{ "@ angular/animations":"^ 8.2.9", "@ angular/cdk":"^ 8.2.3",
"@ angular/core":〜8.2.0",
"@ angular/material":"^ 8.2.3",
"@ angular/router":〜8.2.0", "angular-mat-datepicker":"0.0.2", "angular-material-datepicker":"^ 1.0.2",
"hammerjs":"^ 2.0.8", "ng-material-datetimepicker":"^ 1.19.2",
}
"dependencies": { "@angular/animations": "^8.2.9", "@angular/cdk": "^8.2.3",
"@angular/core": "~8.2.0",
"@angular/material": "^8.2.3",
"@angular/router": "~8.2.0", "angular-mat-datepicker": "0.0.2", "angular-material-datepicker": "^1.0.2",
"hammerjs": "^2.0.8", "ng-material-datetimepicker": "^1.19.2",
},
但是日期选择器图标不起作用,即使该图标也未在视图中显示.我也更新了Angular材质版本,但是没有用.解决此问题的方法是什么?
But the date picker icon is not working, even icon is not showing in the view. I have updated Angular material version as well but that didn't work. What is the solution for this problem?
推荐答案
这是解决我的问题的方法.我只运行下面的代码,现在一切都按预期工作了,
This is the solution for my problem.I just run bellow code and now everything works fine as I expected,
ng add @angular/material
这篇关于Angular Material Date-Picker无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!