角料日期选择服务

问题描述 投票:0回答:1

我使用这个角度素材库:

https://material.angular.io/components/datepicker/api

我试图使用该服务MatDatepicker国际机场他们建议。

datepicker.component.html:

  <mat-form-field class="example-full-width">
    <input matInput [matDatepickerFilter]="myFilter" [matDatepicker]="picker"  placeholder="Choose a date">
    <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
    <mat-datepicker  #picker></mat-datepicker>
  </mat-form-field>

datepicker.component.ts

  constructor(public datePicker: MatDatepickerIntl) { }

  ngOnInit() {

    this.datePicker.changes
      .subscribe(ch => {
        console.log(ch);
      })
  }

但它dosent似乎赶在日期选择器标签的变化。我是否需要该服务附加到我的垫子,日期选择器选择,以及如何?

angular datepicker angular-material angular6
1个回答
0
投票

我认为你需要在app.module.ts文件导入MatDatepickerModule

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

@NgModule({
  declarations: [
    AppComponent,
    .
    .
    .
    .
  ],
  imports: [
    BrowserModule,
    MatDatepickerModule,
    .
    .
    .
    .
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
© www.soinside.com 2019 - 2024. All rights reserved.