问题描述
我已尝试根据文档和以下包含有关环境的信息使用 material-component-datetime-picker.
I have tried to use the material-component-datetime-picker according to the documentation and following information contain about the environment.
角度
角度版本:10.1.0
Angular version : 10.1.0
素材版本:10.1.0
material version : 10.1.0
angular-material-components/moment-adapter - 4.0.1
angular-material-components/moment-adapter - 4.0.1
angular-material-components/datetime-picker - 4.0.2
angular-material-components/datetime-picker - 4.0.2
以下是查看日期时间选择器的代码块.
Following is the code block to view datetime picker.
<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>
当我尝试加载页面时,出现日期时间选择器,但控制台上出现以下错误.
When I try to load the page, datetime-picker appears but following error appears on console.
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 文件
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];
}
似乎错误与我们使用的选择器有关.
Seems like the error is related to picker that we use.
任何原因或缺少任何依赖项?
Any reason or any missing dependencies?
推荐答案
将 @angular-material-components/datetime-picker 更新到 4.0.3 版本对我有用.更新是在几个小时前发布的https://www.npmjs.com/package/@angular-材料组件/日期时间选择器
Updating @angular-material-components/datetime-picker to version 4.0.3 worked for me.The update was released a few hours agohttps://www.npmjs.com/package/@angular-material-components/datetime-picker
这篇关于material-component-datetime-picker-您在需要流的地方提供了“未定义".你可以提供一个 Observable、Promise、Array 或 Iterable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!