Devesh Agrawal Devesh Agrawal - 1 year ago 123
AngularJS Question

Not able to update firebase realtime database in angularjs (web)

This is my code to update a record in firebase.

$scope.EditBrand = function(brand) {
var key =;
var fredNameRef = firebase.database().ref('all-brands/' + key);

fredNameRef.set(brand, function(error) {
if (error) {
alert ('some error')
} else {
alert ('updated')

I checked the key, and its coming correct.

But when calling this function this is the error.

angular.js:12477Error: Firebase.update failed: First argument contains an invalid key ($$hashKey) in path /$$hashKey. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"
at Error (native)

What is wrong with my code or logic??

Answer Source

According to!topic/angular/pI0IgNHKjxw, you should create a temporary object to avoid fields generated by angular. So, add this line in your method : var brandObject = angular.fromJson(angular.toJson(brand)); and use brandObject in the rest of the method.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download