firebase - How to update using angularFireCollection which items not exist previously -
i have parent node text
, want add media
parent node if text
changed update well.
{ parent: { text: 'this content' } }
the media
value third-party callback. how pass update()
? tried {media: callbackval}
not working.
$scope.parent = angularfirecollection(firebaseref.child('parent')); $scope.parent.update(what_to_do_here, function(error){ //something... });
update
maybe question not clear enough.
in firebase js, can update or insert media node.
new firebase(firebaseref).update({ media: 'value'} );
how in `angularfirecollection ?
check out annotated angularfire source: http://angularfire.com/src/angularfire.html#section-38
it looks angularfirecollection.update()
takes key/item , callback function. need edit entry want update directly in angularfirecollection, (e.g. $scope.parent.getbyname('media').value = 'alligator scrimshaw'
) , call $scope.parent.update($scope.parent.getbyname('media'), function(err) { ... })
.
note: 1 rather confusing thing (which maybe misunderstanding) there doesn't seem way add data angularfirecollection id. if media
doesn't exist in firebase, $scope.parent.getbyname('media')
return undefined
. reason, if don't need explicit syncing, , implicit syncing fine, use angularfire object instead of angularfirecollection.
Comments
Post a Comment