This is the source of scheduler.component.ts generated using the UI Builder and modified not to use the data service:
import {Component, ViewChild, AfterViewInit} from '@angular/core';
import {DayPilot, DayPilotSchedulerComponent} from 'daypilot-pro-angular';
import {DataService} from './data.service'; {}
@Component({
selector: 'scheduler-component',
template: `<daypilot-scheduler [config]="config" [events]="events" #scheduler></daypilot-scheduler>`,
styles: [``]
})
export class SchedulerComponent implements AfterViewInit {
@ViewChild('scheduler')
scheduler: DayPilotSchedulerComponent;
events: any[] = [
{
"id": 1,
"resource": "R1",
"start": "2018-09-04T00:00:00",
"end": "2018-09-08T00:00:00",
"text": "Event 1"
},
{
"id": 2,
"resource": "R1",
"start": "2018-09-06T00:00:00",
"end": "2018-09-11T00:00:00",
"text": "Event 2"
}
];
config: any = {
locale: "en-us",
cellWidthSpec: "Fixed",
cellWidth: 40,
crosshairType: "Header",
timeHeaders: [{"groupBy":"Month"},{"groupBy":"Day","format":"d"}],
scale: "Day",
days: DayPilot.Date.today().daysInMonth(),
startDate: DayPilot.Date.today().firstDayOfMonth(),
showNonBusiness: true,
businessWeekends: false,
floatingEvents: true,
eventHeight: 30,
eventMovingStartEndEnabled: false,
eventResizingStartEndEnabled: false,
timeRangeSelectingStartEndEnabled: false,
groupConcurrentEvents: false,
eventStackingLineHeight: 100,
allowEventOverlap: true,
timeRangeSelectedHandling: "Enabled",
onTimeRangeSelected: function (args) {
var dp = this;
DayPilot.Modal.prompt("Create a new event:", "Event 1").then(function(modal) {
dp.clearSelection();
if (!modal.result) { return; }
dp.events.add(new DayPilot.Event({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: modal.result
}));
});
},
resources: [
{
"name": "Resource 1",
"id": "R1"
},
{
"name": "Resource 2",
"id": "R2"
}
]
};
constructor(private ds: DataService) {
}
ngAfterViewInit(): void {
}
}
Does this work for you?