As a newcomer to the world of Ionic, Angular, and TypeScript, I am currently working on developing a calendar that allows users to set appointments (events) and make edits or deletions to them. To achieve this functionality, I have implemented a modal for editing events, with a delete button included. At the moment, I am storing all added events in an object array within a provider class. This provider class contains functions for adding, editing, deleting events, as well as fetching all existing events. The code snippet below demonstrates how this is structured:
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
@Injectable()
export class AppointmentServiceProvider {
currentId: number;
events: { id: number, title: string, startTime: string,endTime: string, allDay:boolean }[];
constructor(public http: HttpClient) {
this.currentId = 0;
this.events =[];
}
getCurrentId(): number{
// Implementation details not shown
}
addEvent(event: { id: number, title: string, startTime: string, endTime: string, allDay:boolean }){
// Implementation details not shown
}
deleteEvent(eventId:number){
// Implementation details not shown
}
getAllEvents():{ id: number, title: string, startTime: string,endTime: string, allDay:boolean }[]{
// Implementation details not shown
}
}
Although the item is successfully removed from the array in the provider upon deletion, my view still displays the deleted event. Below is the HTML code for my page view displaying the calendar:
<calendar [eventSource]="eventSource"
[calendarMode]="calendar.mode"
[currentDate]="calendar.currentDate"
(onEventSelected)="onEventSelected($event)"
(onTitleChanged)="onViewTitleChanged($event)"
(onTimeSelected)="onTimeSelected($event)"
step="30"
class="calendar">
</calendar>
The corresponding TypeScript code backing this view is as follows:
export class AppointmentPage {
// Implementation details not shown
}
editEvent(selectedEvent){
//Implementation details not shown
}
delete(){
//Implementation details not shown
}
Despite these implementations, I am facing issues with the refreshing of the event source after deletion. I am seeking assistance in resolving this issue.