I have a basic method inside a constructor to calculate the current month of the year and output the value to the HTML . However, I can't seem to get it to work.
I'm new to Angular 2 and TypeScript, so this may just be a silly mistake on my behalf :)
calendar.service.ts file:
import { Injectable } from '@angular/core';
import { AngularFireDatabase } from 'angularfire2/database';
@Injectable()
export class GetMonthsService {
private GetMonthsRef = this.fbDB.list('xxxx/xxxx/months');
private GetDaysRef = this.fbDB.list('xxxx/xxxxx/months/Days');
private currentMonth;
constructor(private fbDB: AngularFireDatabase) {}
getMonthsList() {
return this.GetMonthsRef;
}
getDaysList() {
return this.GetDaysRef;
}
getCurrentMonth() {
let currentMonth;
let d = new Date();
return this.currentMonth = d.getMonth();
}
}
home.html:
<ion-content padding>
<ion-list-header>
Current Month Page
</ion-list-header>
{{currentMonth}}
</ion-content>
getCurrentMonthis weird why not justreturn (new Date()).getMonth(). do you know getMonth return int 0..11?constructor()?