javascript - Delete Data from Firebase server Using key or index method -
i need delete entry firebase using angularjs.the problem if use index deletes entries firebase, , if use key method nothing. here code controller.it supposed take key firebase 1 of partials.
$scope.deletecontact = function(key){ contactlist.destroy(key); deletealert.show(); }; contactfactory.factory('contactlist', function($firebaseobject,$firebasearray){ var contact = new firebase("https://mycontactmanager.firebaseio.com/");
this function delete entry firebase
destroy: function(key){ contact.remove(key); }
here code partial
<td>{{contactitem.name}}</td> <td>{{contactitem.email}}</td> <td>{{contactitem.phone}}</td> <td><a href="#/contact/{{key}}" class="btn btn-success btn-xs">view contact</a> <button class="btn btn-danger btn-xs col-sm-offset-1" ng-click="deletecontact(key)\">delete</button> </td> </tr> </tbody>
since ref root of firebase database, need find 1 child , remove child below
ref.child(key).$remove().then(function() { // code after remove });
refer more here https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-firebaseobject-remove
Comments
Post a Comment