我想用TypeScript代码evrey 5s来调用rest-service(SpringBoot),以便给我提供最新的信息,我编写了这段代码,但我得到了信息,但是 我不知道该怎么让他做evrey 5s!任何人都可以帮助我
import {Component} from "@angular/core";
import {NavController, PopoverController} from "ionic-angular";
import { HttpClient } from '@angular/common/http';
import 'rxjs/add/operator/map';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
url:string;
data1:any;
ticket:aiticket[];
result:any=[];
PDV1:any;
constructor(public nav: NavController, public http: HttpClient,public popoverCtrl: PopoverController) {
}
getdata(){
var url='http://localhost:8282/6733/notif';
console.log("Clickeed");
this.data1 = this.http.get(url);
this.data1.subscribe(data1 => {
this.result = data1;
for(let key of data1){
console.log(key.pdv)
console.log(key.data[0]);
this.PDV1=key.data[0]; //i'm using this to call it in the HTML page
}
});}
}