material-component-datetime-picker-您在需要流的地方提供了“未定义”。您可以提供 Observable、Promise、Array 或 Iterable

2024-02-29

我尝试根据文档和以下包含有关环境的信息使用材料组件日期时间选择器。

Angular

角度版本:10.1.0

材质版本:10.1.0

角度材料组件/力矩适配器 - 4.0.1

角度材料组件/日期时间选择器 - 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>

当我尝试加载页面时,出现日期时间选择器,但控制台上出现以下错误。

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)

TS File

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, 5, 10, 15, 20, 25];
}

看来该错误与我们使用的选择器有关。

有什么原因或缺少任何依赖项吗?


将 @angular-material-components/datetime-picker 更新到版本4.0.3为我工作。 该更新于几个小时前发布https://www.npmjs.com/package/@angular-material-components/datetime-picker https://www.npmjs.com/package/@angular-material-components/datetime-picker

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

material-component-datetime-picker-您在需要流的地方提供了“未定义”。您可以提供 Observable、Promise、Array 或 Iterable 的相关文章

随机推荐