【发布时间】:2019-07-14 11:35:48
【问题描述】:
我创建了一个包含离子列表的页面,如果单击该按钮,则会有两个按钮调用 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();
}
}
);
});
}
【问题讨论】:
-
你是替换现有模型还是推向它?
-
看来我要换了。现有模型
-
那么请尝试将新数据推送到模型中。希望它能解决问题。
-
是的,它解决了这个问题。谢谢 !它现在正在工作。
标签: angular ionic-framework ionic4