【发布时间】:2017-12-02 00:31:16
【问题描述】:
我是 Firebase 的新手,想知道如何才能从我的用户数据库中删除一个项目,并且该项目只有在用户插入特定代码(比如 1234)后才会被删除
订单的Json示例
{
"address_id" : "-Kn6eXyJ9XhglrVgA3eo",
"item_qty" : 1,
"payment_id" : "CREDIT",
"product_id" : "item1",
"product_image" : "chicken_maharaja",
"product_name" : "New Chicken Maharaja",
"product_price" : 130,
"status" : "Queued",
"user_id" : "D6yOQ1ZwWwYL69z80xJ0rLTASwG2",
"user_name" : "Bogdan Incrosnatu"
}
显示用户当前订单的控制器
.controller('lastOrdersCtrl', function($scope,$rootScope,fireBaseData,sharedUtils) {
$rootScope.extras = true;
sharedUtils.showLoading();
//Check if user already logged in
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
$scope.user_info = user;
fireBaseData.refOrder()
.orderByChild('user_id')
.startAt($scope.user_info.uid).endAt($scope.user_info.uid)
.once('value', function (snapshot) {
$scope.orders = snapshot.val();
$scope.$apply();
});
sharedUtils.hideLoading();
}
});
})
LastOrder.html
<ion-view style="" class=" " id="page10" title="Orders">
<ion-content class="has-header" padding="true">
<ion-list ng-repeat="item in orders" ng-hide="user.hide">
<ion-item class="item-thumbnail-left" >
<img ng-src="{{'img/fk/'+ item.product_image +'.jpg'}}" >
<a class="badge badge-balanced" style="position: absolute;right:0;" >{{item.status}}</a>
<h4> {{item.product_name}} </h4>
<button ng-click="removeRecord(user)">Delete</button>
</ion-item>
</ion-list>
</ion-content>
</ion-view>
【问题讨论】:
标签: angularjs firebase ionic-framework firebase-realtime-database firebase-authentication