:
$scope.locations = ... // returned from service method
var existingKeys = []; // keep track of existing firebase keys
$scope.locations.forEach(function(location){ // Store the initial location ids
existingKeys.push(location.id);
});
locationService.getNearby(5) // Set 3km as the new radius (was 2km)
.then(function(moreLocations){
moreLocations.forEach(function(newLocation){
/** Prevents pushing duplicates into array by comparing the existing keys **/
if(existingKeys.indexOf(newLocation.id) === -1){
$scope.locations.push(newLocation);
existingKeys.push(newLocation.id); // Append new keys to existingKeys[]
}
})
注 *これはないを行うには、同じオブジェクトをリロードすると、倍の量をxは防ぐ
ありがとう、私はトリックを効率的にやっていると思われるバニラソリューションを思いついた。私はまもなく投稿します –