[英]How to fetch data from service without refreshing the page in Ionic?
[英]How to auto update data on ionic list without refreshing the page
我创建了一个包含 ionic 列表的页面,如果单击该按钮,它会调用 firebase api 并且它会得到更新,则有两个按钮。 它更新的,整个列表得到刷新。 如何停止刷新整个列表。
onLocationDataUpdate() {
// Get current location
this.geolocation.getCurrentPosition().then(position => {
this.location.lat = position.coords.latitude;
this.location.lng = position.coords.longitude;
// Get location data from Firebase
this.connectivityServiceService.getLocations(
this.locatingRange,
this.location.lat,
this.location.lng
);
// Bind data to Ionic list
this.dataSetSubscription = this.connectivityServiceService.geoPointLocationUpdateNotify.subscribe(
locations => {
const locationData = this.connectivityServiceService.getGeoPointLocations();
if (locationData.length > this.maxDataCount) {
const tempLocationData = locationData.slice(0, this.maxDataCount);
tempLocationData.forEach(item => {
if (item.feed_back === undefined) {
item = Object.assign(item, {
feed_back: { count: 0, positive: [], negative: [] }
});
}
});
this.geoPointLocationData = tempLocationData;
this.loader.dismiss();
} else {
const tempLocationData = locationData;
tempLocationData.forEach(item => {
if (item.feed_back === undefined) {
item = Object.assign(item, {
feed_back: { count: 0, positive: [], negative: [] }
});
}
});
this.geoPointLocationData = tempLocationData;
this.loader.dismiss();
}
}
);
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.