Hi bengtler,
Thanks for the response.
I do, I just gave parts of my code I though relevant to make it easier to read. Here is my full code (note: scrolling objects are commented out so that it doesn’t get the error):
// import { Component, ViewChild } from '@angular/core';
// import { NavController, Loading, App, Content } from 'ionic-angular';
import { Component } from '@angular/core';
import { NavController, Loading } from 'ionic-angular';
import { EmployeeService } from '../service/EmployeeService';
import { UtilityService } from '../utils/UtilityService';
import { Employee } from '../model/Employee';
@Component({
templateUrl: 'build/pages/search/search.html',
providers: [EmployeeService, UtilityService]
})
export class SearchPage {
// @ViewChild(Content) content: Content;
// private app: App = null;
private MAX_RESULTS: number = 10000;
private firstResult: number = 0;
private nav: NavController = null;
private loading: Loading = Loading.create();;
private employeeService: EmployeeService = null;
private utilityService: UtilityService = null;
private employeeModel: Employee = null;
private employeeModels: Employee[] = null;
constructor(nav: NavController, employeeService: EmployeeService, utilityService: UtilityService) {
// constructor(content: Content, app: App, nav: NavController, employeeService: EmployeeService, utilityService: UtilityService) {
// this.content = content;
// this.app = app;
this.nav = nav;
this.employeeService = employeeService;
this.utilityService = utilityService;
this.getEmployeeRange(this.firstResult, this.MAX_RESULTS);
}
// ngAfterViewInit() {
// this.content = this.app.getComponent('search-content');
// this.content.addScrollListener(this.onPageScroll);
// }
// onPageScroll() {
// console.log('They see me scrolling...');
// }
getEmployeeRange(firstResult: number, MAX_RESULTS: number) {
this.employeeModels = this.employeeService.getEmployeeRange(firstResult, MAX_RESULTS, this.nav, this.loading);
}
getEmployeeList() {
this.employeeModels = this.employeeService.getEmployeeList(this.nav, this.loading);
}
getEmployee(id: number) {
this.employeeModel = this.employeeService.getEmployee(id, this.nav, this.loading);
}
formatEmployee(employeeModel: Employee) {
if (employeeModel.avatar) {
employeeModel.avatar64 = decodeURIComponent(window.atob(employeeModel.avatar));
}
this.lastAccessDate(employeeModel);
}
lastAccessDate(employeeModel: Employee) {
employeeModel.time = this.displayTime(employeeModel.lastAccessDate);
}
displayTime(lastAccessDate: number) {
var now: number = new Date().getTime();
var timeDiff: number = now - lastAccessDate;
timeDiff /= 1000;
var seconds = Math.round(timeDiff % 60);
timeDiff = Math.floor(timeDiff / 60);
var minutes = Math.round(timeDiff % 60);
timeDiff = Math.floor(timeDiff / 60);
var hours = Math.round(timeDiff % 24);
timeDiff = Math.floor(timeDiff / 24);
var days = Math.round(timeDiff % 7);
timeDiff = Math.floor(timeDiff / 7);
var weeks = timeDiff;
var returnString = weeks + "w " + days + "d";
if (weeks <= 0) {
returnString = days + "d " + hours + "h";
if (days <= 0) {
returnString = hours + "h " + minutes + "m";
if (hours <= 0) {
returnString = minutes + "m";
if (minutes <= 0) {
returnString = "<1m";
}
}
}
}
return returnString;
}
}