1

I have 10 users in my Firebase user node, they are

  1. Diva
  2. Ziva
  3. Destiny
  4. Daniel
  5. James
  6. Zionnite (This is Me)
  7. Jessy
  8. Johan
  9. Precious
  10. 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.

  1. Diva
  2. Ziva
  3. Destiny
  4. Daniel
  5. James
  6. Jessy
  7. Johan
  8. Precious
  9. Kings

You see zionnite is no longer in the list.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Zionnite
  • 291
  • 4
  • 13
  • once you have loged in you can push that particular username into an array and the you can check the string in each or the names you are getting and do not push that name into array so that you can avoid duplicate and then you can push the remaining names into that array and also ng-repeat does not allow duplicate. – Mohan Gopi Jun 14 '16 at 13:01
  • @MohanGopi , thank you for your time but can you please show it me with code (it will really help alot)... thanks again – Zionnite Jun 14 '16 at 13:23
  • Client-side filtering is probably easiest for this: http://stackoverflow.com/questions/27671714/how-to-filter-out-a-user-using-ng-repeat-within-firebase-and-angularfire – Frank van Puffelen Jun 14 '16 at 13:32
  • yes you are right are you getting those name from backend – Mohan Gopi Jun 14 '16 at 13:39
  • @FrankvanPuffelen , thank you sir. i will do that right away – Zionnite Jun 14 '16 at 13:39
  • HURRAY.... its working now.. thanks to you for your help – Zionnite Jun 14 '16 at 15:23

0 Answers0