@Oliver2000 wrote:
Hi everybody
I have a Application where I try to include Firebase. I got it work so far but the way I included the get request in my controller my script just continue without waiting for the data. I would like to convert my request into a request with a promise.
something similar as I used before with normal $http requests:
$http(http_req).then(function mySucces(data) { // Success }, function myError(data) { //something was wrong });
My current controller looks like this:
.controller('NoticiasCtrl', function(FURL, $scope, $state, $http, $ionicLoading, $rootScope, $firebaseObject, $firebaseArray) { $scope.newslist = []; $scope.doRefresh = function() { //Show loading comment $ionicLoading.show({ template: '<p>Carregando notícias...</p><ion-spinner></ion-spinner>' }); var ref = firebase.database().ref('news'); $scope.newslist = $firebaseArray(ref); $ionicLoading.hide(); $scope.$broadcast('scroll.refreshComplete'); }; $scope.doRefresh(); })
Basically I want to have the line "var ref = firebase...." with a promise. And if the data is received continue with $scope....
Thank you in advance
Posts: 2
Participants: 2