2016-04-26 13 views
2

私は私のデータは非常に似firebaseに挿入したい挿入されていません。角度ベース。データが正しく

cities:{ 
    Tokyo:{ 
     name: "Tokyo, JP" 
    } 
    London:{ 
     name: "London, UK" 
    } 

    and so on... 

私はオンラインGUIから手動でいくつかのデータを挿入:cities

しかし残念ながら、それがそのように挿入されます:minsk

私のコード

Firebase工場:

export default function CitiesFactory($firebaseArray, Firebase) { 
    'ngInject'; 
    var ref = new Firebase("https://name.firebaseio.com/"); 
    return $firebaseArray(ref.child('cities')); 
} 

コントローラ(機能の追加):

$scope.addoras = function(city) { 
     CitiesFactory.$add({ 
      city: { 
       name: city 
      } 
     }).then(function(CitiesFactory) { 
      var id = CitiesFactory.key(); 
      console.log('Added Contact ' + id); 
      $scope.addorasmodel = ''; 

     }); 
    }; 

誰かが私を助けることができますか?

+0

またhttp://stackoverflow.com/questions/36845390/firebase-help-avoidを見ます-new-id-on-new-push/36846118#36846118 –

答えて

2

$ add()を使用すると、documentationのように固有のプッシュIDが生成されます。

あなたはこれらのユニークなIDを避けたい場合は、(設定を使用することができますに)またはupdate()(Documentation

var ref = new Firebase("https://name.firebaseio.com/"); 
ref.set({ 
    city: { 
     name: city 
    } 
}); 

var ref = new Firebase("https://name.firebaseio.com/"); 
ref.update({ 
    city: { 
     name: city 
    } 
}); 
+0

ありがとうございます..... –

関連する問題