Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions src/components/calendar/calendar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,9 @@ export class CalendarComponent {
private modalCtrl: ModalController,
private alertCtrl: AlertController,
private calendarService: CalendarService) {

let events =this.eventSource;
this.eventCalendarList =
this.calendarService.getEventsCalendarList()
.snapshotChanges()
.map(
changes => {
return changes.map(c => {
return({
key: c.payload.key,
...c.payload.val()
})
})
})

this.eventCalendarList = this.calendarService.getEventsCalendarList();
this.eventCalendarList.subscribe(
(res) => {
res.map(event => {
Expand Down
11 changes: 10 additions & 1 deletion src/components/calendar/calendar.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ export class CalendarService {
}

getEventsCalendarList() {
return this.eventCalendarListRef;
return this.eventCalendarListRef.snapshotChanges()
.map(
changes => {
return changes.map(c => {
return({
key: c.payload.key,
...c.payload.val()
})
})
});
}

// updateEventCalendar(eventData: EventCalendar) {
Expand Down
16 changes: 14 additions & 2 deletions src/pages/home/home.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<ion-header>
<ion-navbar>
<ion-buttons start>
<ion-buttons left>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
</ion-buttons>
<ion-title center>Home</ion-title>
<ion-title>Home</ion-title>
</ion-navbar>
</ion-header>

<ion-content padding>
<img src="assets/imgs/SoImpec.png" class="logo" />


<ion-buttons left>
<button ion-button (click)=getEventsFromCalendar()>
GET EVENTS
</button>
</ion-buttons>

<ion-list *ngFor="let event of events">
<ion-item>{{event?.title}}</ion-item>
</ion-list>

</ion-content>

16 changes: 14 additions & 2 deletions src/pages/home/home.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CalendarService } from './../../components/calendar/calendar.service';
import { Component } from '@angular/core';
import { NavController, IonicPage } from 'ionic-angular';

Expand All @@ -7,8 +8,19 @@ import { NavController, IonicPage } from 'ionic-angular';
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
}

private events;
private error;
private test = "hello world";
constructor(public navCtrl: NavController, private calendarService: CalendarService) {
}

getEventsFromCalendar() {
this.calendarService.getEventsCalendarList().subscribe(
(res) => {
this.error = JSON.stringify(res);
this.events = res;
}
);
}
}