Кто-нибудь может сказать мне, как изменить эту часть scheduler.component.ts :
events: (start: any, end: any, timezone: any, callback: any) => {
callback(this.events);
}
и эту часть cal.component.ts :
this.events = this.getEvents();
, чтобы я мог в функции getEvents () в cal.component.ts , вызвать метод: this.BookingService.getBookings (this.ip, начало, конец ). подписаться (
вместо this.BookingService.getBookings (this.ip) .subscribe (
Весь код нижеработает сейчас как надо
, но я не хочу загружать все заказы, если календарь показывает диапазон от начальной даты до конечной даты. Параметры start и end правильно установлены в scheduler.component.ts.
Ниже приведены только важные части приложения:
cal.component.html
<div>
<ds3-schedule (onEventClick)="handleEventClick($event)" (onEventResize)="resizeEvent($event)" (onEventDragStop)="saveEvent($event)"
(onDayClick)="showDialog($event)" editable="true" defaultView="timelineMonth" [header]="header" [resourceColumns]="resourceColumns"
[resources]="resources" [(events)]="events" [defaultDate]="defaultDate" [aspectRatio]="1.2" [resourceAreaWidth]="85"
titleFormat="YYYY-MM-DD dddd" [contentHeight]=330 nowIndicator="true" scrollTime="00:00" locale="pl"
(onViewRender)="onViewRender($event)" (onEventLoading)="loadingEvents($event)">
</ds3-schedule>
</div>
scheduler.component.ts
@Component({
selector: 'ds3-schedule',
styles: ['./cal.component.css'],
template: '<div [attr.style]="style" [attr.class]="styleClass"></div>'
})
export class SchedulerComponent implements AfterViewInit, OnDestroy, DoCheck {
@Input() events: any[];
ngAfterViewInit() {
this.schedule = jQuery(this.el.nativeElement);
if (this.schedule.fullCalendar) {
this.schedule.fullCalendar({
events: (start: any, end: any, timezone: any, callback: any) => {
callback(this.events);
}
}
cal.component.ts
@Component({
selector: 'ds-schedule',
styles: ['./cal.component.css'],
templateUrl: './cal.component.html',
//changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
CustomerService,
CalService,
BookingService
]
})
ngOnInit() {
this.optionConfig = {}
this.header = {
left: 'prev,next today',
center: 'title',
right: 'timelineMonth, timelineYear'
};
this.events = this.getEvents();
this.resources = this.getResources();
}
getEvents(): MyEvent[] {
var events: MyEvent[] = [];
this.ipservice.getIP().subscribe(
d => {
this.ip = d;
this.BookingService.getBookings(this.ip).subscribe(
data => {
this.bookings = data;
this.bookings.forEach(booking => {
events.push(this.bookingToEvent(booking));
});
}
)
}
);
return events;
}