我有一个subscribe-in-typescript,它从我自己的ASP.NET数据库中提取位置。但是,他们只提取一次数据,但位置应该实时更新。我如何让我的可观察对象自动更新?
.MarkForCheck()
或
).
getLocations(){
console.log("Get them all!");
this.API.getAllLocations().subscribe(result =>{
this.locations = result;
console.log(this.locations);
this.addLocationMarkers();
this.ref.markForCheck();
});
}
getAllLocations(): Observable<Location[]> {
return this._http.get<Location[]>(this.url + "location/", this.headers);
}
console.log(this.locations)
在我的浏览器中只调用一次。当数据库中的基础数据发生更改时,为什么不调用它?