2013-08-14 4 views
0

나는 firebase에서 이것을 가지고있다. firebase에있는 속성 이름을 얻는 방법

{ 
'users': 
    { 
    'random1': 
     { 
     'name': 'David' 
     } 
    },{ 
    'random2': 
    { 
     'name': 'Dan' 
    } 
    } 
} 

어떻게 angularFire를 사용하여 random1random2을 나열합니다. 내가하고 싶은 것은 random1과 random2를 얻은 다음 나중에 제거하기 위해 URL을 전달하는 것입니다.

ref.child('users/' + therandomidhere); 
$scope.remove = userRef.remove(); 

답변

1

난 당신이 뭘 하려는지 정확히 모르겠지만, 당신은 단순히 null로 설정하여 객체의 속성을 제거 할 수 있습니다. 예 :

function MyController($scope, angularFire) { 
    angularFire(ref, $scope, "users", {}).then(function() { 
    // You can delete random1 by doing: 
    $scope.users["random1"] = null; 
    // Or: 
    delete $scope.users["random1"]; 
    // You can enumerate all the keys by: 
    for (var key in $scope.users) { 
     console.log(key); 
    } 
    }); 
} 

희망이 있습니다.

+0

나는 당신의 방법을 시도했지만 작동하지 않았다. 나는 플 런커를 추가했다. 그것을 확인하십시오. http://plnkr.co/edit/iOxxrPeil4MrKnVnGE37?p=preview – vzhen

+1

splice가있는 배열에서 삭제하려고하지만 개체입니다. Fixed Plunkr : http://plnkr.co/edit/b1LXs4xtKasHByuhDNBk? – Anant

관련 문제