javascript - Displaying Special Case Of Sorted Firebase Arrays (with AngularJS) -
so have set of clubs, , set of users. each club , each user has specific latitude , longitude. showing clubs user easy ng-repeat, i'm trying show clubs within distance of each user. i've come far:
var arr = []; $scope.clubs.$loaded().then(function() { angular.foreach($scope.clubs, function(value, key) { if($scope.getdistance(value.lng, value.lat) == true) { console.log(value.name + " it's close enough!"); arr.push( {id: value.$id, description: value.description, name: value.name}); } }); console.log(arr); }); $scope.narr = arr; is there more elegant way this? i'm singling out data firebase array, , putting smaller array (arr) , ng-repeating through it. it's not firebase array... ideas?
p.s. don't think can use of built in firebase sorting, because distance unique each user, , each location requires latitude , longitude.
why not evaluate $scope.getdistance() in template?
you'll need create $firebasearray() on $scope.
$scope.cabyns = $firebasearray(ref); then in template can call $scope.getdistance() item in ng-repeat. using ng-if direction, can state whether should loaded.
<ul> <li ng-repeat="item in cabyns"> <span ng-if="getdistance(item)"> {{ item.name }} <span> </li> </ul> another thing try doing using geofire if you're doing geofencing.
Comments
Post a Comment