currently This is how i access my Api via HTTP
Provider
vchats.ts
#########################################
import { Injectable } from ‘@angular/core’;
import { Http, Headers } from ‘@angular/http’;
import ‘rxjs/add/operator/map’;
/*
Generated class for the Vchats provider.
See https://angular.io/docs/ts/latest/guide/dependency-injection.html
for more info on providers and Angular 2 DI.
*/
@Injectable()
export class Vchats {
public headers: Headers;
constructor(public http: Http) {
this.http = http;
this.headers = new Headers();
this.headers.append(‘Content-Type’, ‘application/json’);
console.log(‘Hello Vchats Provider’);
}
viChats(ids){
var response = this.http.get('http://localhost/aa1/my/getchatdetail/'+ids).map(res => res.json());
return response;
}
}
#################
The From The Controller
chats.ts
################################################
import { Component } from ‘@angular/core’;
import { ViewChild } from ‘@angular/core’;
import { NavController, NavParams } from ‘ionic-angular’;
import { Http, Headers } from ‘@angular/http’;
import { Vchats } from ‘…/…/providers/vchats’;
//import { FORM_DIRECTIVES, FormBuilder, FormGroup, Validators, AbstractControl} from ‘@angular/forms’;
import { FormBuilder, FormControl, FormGroup, AbstractControl, Validators } from ‘@angular/forms’;
/*
Generated class for the Chats page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
selector: ‘page-chats’,
templateUrl: ‘chats.html’,
//directives: FORM_DIRECTIVES
})
export class ChatsPage {
authForm: FormGroup;
dchats: any[];
// @ViewChild(mychats) content: ChatsPage;
constructor(public navCtrl: NavController, public navParams: NavParams, public vChat: Vchats, public http: Http) {
var a = navParams.get(‘ci_id’);
this.vChat.viChats(a).subscribe(data => {
this.dchats = data.getchatdetail;
});
console.log('logged');
}
lodchat(){
var b = this.navParams.get(‘ci_id’);
this.vChat.viChats(b).subscribe(data => {
this.dchats = data.getchatdetail;
});
console.log('chat loaded');
}
}
So please how do i implement the Timer that will call the http request to the API every 5secs?