Deleting firebase data that is displayed as a Table using AngularJS

﹥>﹥吖頭↗ 提交于 2019-12-11 04:34:35

问题


I have an HTML file which displays a data set in firebase as a table. As the data is in firebase I am using (key,client) in clientInfo to get the key as well. This key is used for the purpose of deleting a row.

<table class="meeting">
    <tr ng-repeat="(key, client) in clientInfo">
        <td>{{ client.name }}</td>
        <td>{{ client.discount }}</td>
        <td>{{ client.vms }}</td>
        <td><button class="btn btn-delete tooltip" ng-click="deleteClient(key)">
            <span>Delete this client</span></button>
        </td>
    </tr>
</table>

But while clicking the button, the deleteClient(key) function is not called. Is it because the information of key isnt available on a Cell(td) level and is available only on a Row(tr) level in the HTML?

I am using an older version of Firebase where $as.Object() is required to store data as an Object.

My controller in Angular

myApp.controller('DataController', function ($scope, $rootScope, $firebase, FIREBASE_URL) { 
var ref = new Firebase(FIREBASE_URL + '/clientInfo');
var clientInfo = $firebase(ref);
$scope.clientInfo = clientInfo.$asObject();
$scope.deleteClient = function(key) {
    clientInfo.$remove(key);
};

Is it possible to do this in Table format? If so, what am I doing wrong? Please help me solve this issue

来源:https://stackoverflow.com/questions/29787182/deleting-firebase-data-that-is-displayed-as-a-table-using-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!