我正在研究Ionic和firebase的一个项目。问题是,当我尝试更新数据库中的数据时,应用程序的视图将切换到另一个。尝试了很多工作,但还没有修复。在gif中,我们可以看到视图正在从属性视图变为列表视图,从而使离子模态发生变化。有没有人在此之前遇到过这个问题或有解决方案请帮助我完成这个任务。谢谢。Error Gif
此代码段打开模态并更新数据库:
$ionicModal.fromTemplateUrl('templates/unitinfopopup.html', {
scope: $scope
}).then(function(modal) {
$scope.infomodal = modal;
});$scope.openinfoModal = function(pid) {
// Get a database reference to our posts
$scope.userd=PeopleLoginService.getPeople();
var reflogn = new Firebase("https://pspacedb.firebaseio.com/Users/"+$scope.userd.$id);
var authDatas = reflogn.getAuth();
$scope.ppointid="";
if (authDatas) {
reflogn.on("value", function(snapshot) {
$scope.ppointid=snapshot.val().ppoint;
$scope.ppointid=$scope.ppointid-1;
}, function (errorObject) {
});
if ($scope.ppointid>=1) {
reflogn.update({ ppoint:$scope.ppointid});
$scope.unitid='';
var ref = new Firebase("https://pspacedb.firebaseio.com/Listing/"+pid);
// Attach an asynchronous callback to read the data at our posts reference
ref.on("value", function(snapshot) {
$scope.unitid=snapshot.val();
}, function (errorObject) {
});
$scope.infomodal.show();
}
else {
var alertPopup = $ionicPopup.alert({
title: 'No Enough Credits!',
template: 'You can buy credits from our store.'
});
}
}
else {
var alertPopup = $ionicPopup.alert({
title: 'Not LoggedIn!',
template: 'Please Login to Show Profile.'
});
}
};
HTML code:
<a class="tab-item" style="margin-top: 2.75%" type="button" ng-click="openinfoModal(properyid)"><i class="my-icon ion-information-circled"></i><p style="font-size: 13px">Unit Info</p></a>
更新代码:
reflogn.update({ ppoint:$scope.ppointid});