问题
I am currently experiencing a problem with my ionic calendar in that I am able to save input events in an array, retrieve the array and display the info on console. However I am unable to utilize the array and display the array in its original list. I am a noob at ionic:-) so any help will go a long way.
Here is my code so far:
//where data is received from a modal and received as(data)
modal.onDidDismiss(data =>{
if (data){
let eventData=data;
eventData.startTime= new Date(data.startTime);
eventData.endTime= new Date(data.endTime);
//initialization of array
//this is where the array is displayed
let events=this.eventSource;
events.push(eventData);
this.eventSource=[];
setTimeout(() =>{
this.eventSource=events;
});
//saving the array of events
this.storage.set('data1',JSON.stringify(events));
}
});
}
//once view is loaded the saved array should display as before the page is closed.
ionViewWillEnter() {
console.log("Showing the first page!");
this.storage.get('data1').then((data1)=>{
if(data1){
console.log(JSON.parse(data1));
return JSON.parse(data1);
}
});
来源:https://stackoverflow.com/questions/45924904/ionic-2-saving-multiple-calendar-events