I have 10 users in my Firebase user node, they are
- Diva
- Ziva
- Destiny
- Daniel
- James
- Zionnite (This is Me)
- Jessy
- Johan
- Precious
- Kings
and I have a code that lists all users from my user list, the code:
service.js:
app.service("ListAllUserService",function($q, $rootScope, $ionicPopup, $firebaseAuth, $firebaseObject, $firebaseArray, $localStorage, $ionicLoading){
var self ={
'data' : '',
'Loading': true,
"hasMore":true,
"page":10,
"next_page":3,
'users' : '',
'lastKnownDomainValue': [],
'ListUser': function(){
var deferred = $q.defer();
var usersRef = new Firebase("https://bigzill.firebaseio.com/users");
var usersRef2 = new Firebase("https://bigzill.firebaseio.com");
var authData = usersRef.getAuth();
$rootScope.scrollRef = new Firebase.util.Scroll(usersRef,"username");
if(authData){
self.users = $firebaseArray($rootScope.scrollRef);
$rootScope.scrollRef.scroll.next(self.page);
self.Loading =false;
deferred.resolve(self.users);
}else{
console.log("User not Authenticated");
deferred.reject(data);
}
return deferred.promise;
}
}
self.ListUser();
return self;
});
controller.js:
app.controller('ListAllUserCtrl', function($scope, $rootScope, $state, $ionicPopup, $firebaseAuth, $firebaseObject, $firebaseArray, PresenceService, $localStorage, $ionicLoading, ListAllUserService){
$scope.Get =ListAllUserService;
$scope.LoadAllUser =function(){
$ionicLoading.show({template:'Loading...'});
$scope.Get.ListUser().then(function(data){
$scope.users =data;
console.log($scope.users);
$ionicLoading.hide();
});
}
$scope.LoadAllUser();
});
I want to make sure that the logged in user is not displayed from the return results.
- Diva
- Ziva
- Destiny
- Daniel
- James
- Jessy
- Johan
- Precious
- Kings
You see zionnite is no longer in the list.