angular-promise

Data from ES6 promise doesn't render on the page until I click on it?

孤街浪徒 提交于 2021-02-05 11:27:27
问题 I an using Ionic for my app with a connection to Firebase to pull data. I created a promise in a factory to pull data down and thought it should render the data on the screen once it finishes but I'm getting nothing until I touch the screen? I get no error and the data does indeed come. Factory: all: function () { return new Promise ((resolve, reject) => { firebase.database().ref('desks').once('value').then(snapshot => { let desks = [] snapshot.forEach((child) => { desks.push(child.val()); })

Export value [object Promise] use angular 8?

99封情书 提交于 2020-06-17 09:15:11
问题 My code async loginStatus() { return new Promise((resolve) => { firebase.auth().onAuthStateChanged(firebaseUser => resolve(firebaseUser)) }) } async checkLoginStatus(){ const userObject = await this.loginStatus() return userObject } How export value don't use this syntax this.checkLoginStatus().then(e => console.log(e)); or how save value in a variable . output if not this syntax => checkLoginStatus[object Promise] 回答1: make your method async. lets say you was doing it in a method name

wait for promises in onbeforeunload

半腔热情 提交于 2020-06-11 17:04:19
问题 I want to send a $http.get if the page gets closed. Then I stumbold upon a problem where promises can't get resolved because if this one last method returns, the page gets destroyed. The following does not work because onbeforeunload can't resolve promises / does not wait for them: window.onbeforeunload = function( $http.get('http://someth.ing/update-state?page=unloaded').then(function(){ // never called... never sent... } } I know, you can use default sync HTTP Methods but the question is

AngularJS 1.7.9 : how to debug “Possibly unhandled rejection: {}”?

血红的双手。 提交于 2020-03-04 07:31:27
问题 I am aware of siiar questions, such as Angularjs 1.7.9 - Possibly unhandled rejection and those mentioned in it as duplicates. However, my code does not use promises (that I am aware of; certainly no $promise or $http ). I am just knocking up a simple ui-router demo for a friend. It is just two views, each with a button that toggles to the other view. It works just fine with AngulrJs 1.5, and breaks with the above error in 1.7. A simple as it is, it's a bit too much code to post. In case,

Chaining subsequent promises and wait for all to resolve

不羁的心 提交于 2020-02-06 03:15:15
问题 I have already read some articles and questions about promises but I still have problems to get my head around them. Here's what I want to do: My application should request properties from a device. The properties can be represented as single value or as an Array. Every property has attributes, that give me information about it (like is it an array, is it writeable, etc.). So my first attempt was to read the attributes of an property first. So I can see if I need to read a single value or an

Chaining subsequent promises and wait for all to resolve

余生长醉 提交于 2020-02-06 03:15:06
问题 I have already read some articles and questions about promises but I still have problems to get my head around them. Here's what I want to do: My application should request properties from a device. The properties can be represented as single value or as an Array. Every property has attributes, that give me information about it (like is it an array, is it writeable, etc.). So my first attempt was to read the attributes of an property first. So I can see if I need to read a single value or an

$uibModalInstance.close not working

ぐ巨炮叔叔 提交于 2020-02-04 01:53:23
问题 I have the following code: .service('loginModal', function($rootScope, $uibModal) { function updateUserData(user, data) { Object.keys(data).forEach(function(key) { user.facebook[key] = data[key]; }); return user.$update(); } return function() { var instance = $uibModal.open({ templateUrl: 'tpls/modals/login.html', controller: function($scope, $uibModalInstance, facebookService, UserService) { function updateUserData(user, data) { Object.keys(data).forEach(function(key) { user.facebook[key] =

Resolve and q.All() issue

微笑、不失礼 提交于 2020-01-25 11:00:51
问题 I am trying to resolve a method like below using ui-router $stateProvider .state('abc', { url: 'xyz', templateUrl: 'templateURL', controller: ctrl, resolve:{ data: function(someService){ data = someService.init(); return data; } } }) And my service code looks like this var someObject = { data1: ..., data2: ...., ... } return{ init: function(){ promise1 = ... promise2 = ... promise3 = $http.get('someurl').then(function(){ ... ... //do some manipulation with someObj return someObject; }); $q

AngularJS : returning data from service to controller

点点圈 提交于 2020-01-21 00:07:33
问题 I am trying to create a service to get json and pass it to me homeCtrl I can get the data but when a pass it to my homeCtrl it always returns undefined. Im stuck. My Service: var myService = angular.module("xo").factory("myService", ['$http', function($http){ return{ getResponders: (function(response){ $http.get('myUrl').then(function(response){ console.log("coming from servicejs", response.data); }); })() }; return myService; } ]); My Home Controller: var homeCtrl = angular.module("xo")