material-component-datetime-picker-您在期望流的位置提供了“ undefined”您可以提供一个Observable,Promise,Array或Iterable

问题描述

我已尝试根据文档使用material-component-datetime-picker,以下信息包含有关环境的信息。

角度

角度版本:10.1.0

材料版本:10.1.0

angular-material-components / moment-adapter-4.0.1

angular-material-components / datetime-picker-4.0.2

以下是用于查看日期时间选择器的代码块。

<mat-form-field> <input matInput [ngxMatDatetimePicker]="picker" placeholder="Choose a date" [formControl]="tab._from" [min]="minDate" [max]="maxDate" [disabled]="disabled"> <mat-datepicker-toggle matSuffix [for]="picker"> </mat-datepicker-toggle> <ngx-mat-datetime-picker #picker [showSpinners]="showSpinners" [showSeconds]="showSeconds" [stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond" [touchUi]="touchUi" [color]="color"> </ngx-mat-datetime-picker> </mat-form-field>

当我尝试加载页面时,出现datetime-picker,但控制台上出现以下错误。

ERROR TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable,Promise,Array,or Iterable. at subscribeTo (subscribeTo.js:27) at subscribeToResult (subscribeToResult.js:11) at MergeMapSubscriber._innerSub (mergeMap.js:59) at MergeMapSubscriber._tryNext (mergeMap.js:53) at MergeMapSubscriber._next (mergeMap.js:36) at MergeMapSubscriber.next (Subscriber.js:49) at Observable._subscribe (subscribeToArray.js:3) at Observable._trySubscribe (Observable.js:42) at Observable.subscribe (Observable.js:28) at MergeMapOperator.call (mergeMap.js:21)

enter image description here

TS文件

export class Picker {
   @ViewChild('fromPicker') fromPicker: any;
  @ViewChild('toPicker') toPicker: any;

  public date: moment.Moment;
  public disabled = false;
  public showSpinners = true;
  public showSeconds = false;
  public touchUi = false;
  public enableMeridian = false;
  public minDate: moment.Moment;
  public maxDate: moment.Moment;
  public stepHour = 1;
  public stepMinute = 1;
  public stepSecond = 1;
  public color: ThemePalette = 'primary';

  public stepHours = [1,2,3,4,5];
  public stepMinutes = [1,5,10,15,20,25];
  public stepSeconds = [1,25];
}

似乎错误与我们使用的选择器有关。

是任何原因还是缺少依赖项?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)