FirebaseObject
$save: se aplica al $scope. Se enlaza al $scope primero y luego se realizan acciones necesarias.//var ref = new Firebase('https://cplearn.firebaseio.com')
var ref = firebase.database().ref();
var vm=this;
vm.object = $firebaseObject(ref.child('example'));
vm.initializeObject = function(){
vm.object.name = "Old name";
vm.object.title = "Old title";
vm.object.date = "Old date";
vm.object.$save();
}
// Function that makes changes an than saves.
vm.changeObject = function () {
vm.object.name = "New name!";
vm.object.$save();
};
Referencias:https://github.com/firebase/angularfire/blob/master/docs/reference.md#save
https://github.com/firebase/angularfire/issues/674
http://plnkr.co/edit/RgcInFVnQx187QDpe7pi?p=preview (incorrecto)
http://plnkr.co/edit/P6Z00NIznO8KLdvkvbCC?p=preview (correcto)
0 comentarios:
Publicar un comentario