When comparing angularfire .$save() to firebase .push(), what are the differences? I understand that push() generates a unique key when data is stored, but I'm having trouble replicating this behavior with angularfire. Should I stick to using .push() or is there a way to achieve the same result with $save()? In what scenarios would you recommend using $save() over .push()?
Here is an example using $save()...
var fb = new Firebase(FIREBASE_URI).child('Test');
var article = $firebaseObject(fb);
article.Foo = "bar";
article.$save().then(function(fb) {
console.log(fb.key() === article.$id); // true
}, function(error) {
console.log("Error:", error);
});
And here is an example using .push()...
var article = new Firebase(FIREBASE_URI).child('Articles');
article.push({
title: $scope.article.title,
post: $scope.article.post
}, function(error) {
if (error) {
console.log("Error:", error);
}
});
What are the advantages/disadvantages and typical use cases for each method?