hey i need help when i run my code ios device gives me Nan pls what is my problem in my code?
html
<ion-navbar>
<button ion-button menuToggle *ngIf="!checkIfStaDetail">
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>İstatistik</ion-title>
<ion-buttons end *ngIf="checkIfStaDetail">
<button ion-button icon-only (click)="closeModal()">
<ion-icon name="close"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content overflow-scroll="true">
<ion-list *ngFor="let item of t_list">
<button ion-button full id="{{ item.id }}">
{{ item.month_text }} {{ item.year }}
</button>
<mwl-calendar-month-view
class="calendar-comp"
[viewDate]="item.date"
[events]="item.calEvents"
[weekStartsOn]=1
(dayClicked)="goToDetail($event.day.date)">
</mwl-calendar-month-view>
</ion-list>
</ion-content>
ts
import { Component } from ‘@angular/core’;
import { IonicPage, NavController, NavParams, LoadingController, ViewController } from ‘ionic-angular’;
import { Store } from ‘@ngrx/store’;
import { AppState } from ‘…/…/services/app-state’;
import { OnInit, TemplateRef, ViewChild } from ‘@angular/core’;
import { CalendarEvent } from ‘angular-calendar’;
import { Content } from ‘ionic-angular’;
import { StatisticsDetailPage } from ‘…/statistics-detail/statistics-detail’;
import { Http, Headers, RequestOptions } from ‘@angular/http’;
@IonicPage()
@Component({
selector: ‘page-statistics’,
templateUrl: ‘statistics.html’
})
export class StatisticsPage {
@ViewChild(Content) content: Content;
colors: any = {
red: {
primary: ‘#ff0000’
},
green: {
primary: '#00ff00'
},
black: {
primary: '#000000'
}
}
months: Array = [
‘Ocak’, ‘Şubat’, ‘Mart’, ‘Nisan’, ‘Mayıs’, ‘Haziran’, ‘Temmuz’, ‘Ağustos’, ‘Eylül’, ‘Ekim’, ‘Kasım’, ‘Aralık’
];
t_list: any;
date: Date;
year: any;
month: any;
month_text: any;
daysOfMonth: any;
event: CalendarEvent;
calEvents: CalendarEvent;
fakeYear: number;
loading: any;
checkIfStaDetail: boolean = false;
constructor(
public navCtrl: NavController,
public navParams: NavParams,
public loadingCtrl: LoadingController,
public viewCtrl: ViewController,
public http: Http,
private store: Store) {
this.checkIfStaDetail = this.navParams.get('isStaDetail');
this.t_list = [];
this.fakeYear = new Date(Date.now()).getFullYear();
this.presentLoading();
let timerTotal = setInterval(() => {
for(let i = 1; i <= 12; i++){
this.init(new Date(this.fakeYear + "," + i.toString()));
this.t_list.push({
id: i,
month_text: this.month_text,
year: this.year,
date: this.date,
calEvents: this.calEvents
});
}
this.dismissLoading();
let tt = setInterval(() => {
let element = document.getElementById((new Date(Date.now()).getMonth() + 1).toString());
element.scrollIntoView();
clearInterval(tt);
}, 400);
clearInterval(timerTotal);
}, 400);
}
paramDate: Date;
goToDetail(param){
if(this.checkIfStaDetail){
this.paramDate = param;
this.closeModal();
}
else{
this.navCtrl.push(StatisticsDetailPage, {
//dateStart: param.getDate() + “.” + param.getMonth() + “.” + param.getFullYear()
dateStart: param
});
}
}
ionViewDidLoad() {
}
init(date){
this.date = date;
this.year = this.date.getFullYear();
this.month = this.date.getMonth() + 1;
this.month_text = this.months[this.month - 1];
this.daysOfMonth = new Date(this.year, this.month, 0).getDate();
this.calEvents = [];
for(let i = 1; i <= this.daysOfMonth; i++){
this.store.select(state => state.mistatistiks).forEach(sta => {
for(let s of sta){
if(new Date(s.date).getFullYear() == this.year && (new Date(s.date).getMonth() + 1) == this.month && new Date(s.date).getDate() == i){
this.createEvent(new Date(this.year.toString() + "," + this.month.toString() + "," + i.toString()), "Egzersiz", this.colors.green);
break;
}
}
});
}
}
createEvent(date, title, color){
this.event = {
start: date,
title: ‘’,
color: color
}
this.calEvents.push(this.event);
}
presentLoading(){
this.loading = this.loadingCtrl.create();
this.loading.present();
}
dismissLoading(){
this.loading.dismiss();
}
closeModal(){
this.viewCtrl.dismiss(this.paramDate);
}
}