Questions tagged [angular-promise]

Angular's $q promises provide a powerful abstraction over flow control. If you tag your question with this tag, consider also tagging it with "promise" tag. This tag is also appropriate for questions about angular and promises not relaying to $q directly.

Angular's $q promises provide a powerful abstraction over flow control. If you tag your question with this tag consider also tagging it with the promise tag.

This tag is also appropriate for questions about angular and promises not relaying to $q directly.

2114 questions
6
votes
1 answer

$http promise chain running in wrong order

I am new to angularjs. My goal is very simple. I want to make an ajax call to get data and, once complete, I want to make a second call to get another set of data that is dependent on information in the first set. I'm trying to do this utilizing…
dshockey
  • 185
  • 1
  • 10
6
votes
2 answers

AngularJS Promise retries

I am having some trouble getting a retry function to work and was hoping for some assistance. I have a $resource that I want to have called until a success condition occurs or the maximum retries has been exceeded. The issue I seem to be running…
Brian
  • 2,294
  • 6
  • 30
  • 51
6
votes
3 answers

How to pass $q to angular directive link function?

I need to use $q a link function of my directive. I need it to wrap possible promise that is retuned by one of arguments (see the example below). I don't know however, how to pass $q dependency to a this function. angular.module('directives') …
mrzasa
  • 22,895
  • 11
  • 56
  • 94
6
votes
3 answers

Waiting for $rootScope value to resolve in Angular before page load

So I'm running into this problem where I'm using ngView and I have a navigation bar that is static throughout like so:
This nav.html,…
Himmel
  • 3,629
  • 6
  • 40
  • 77
6
votes
2 answers

AngularJS promise is not resolved multiple times using $interval

Surprised to see why the angularjs promise is not resolved multiple times using $interval service. Below is my code. The variable i is incremented multiple times, however the promise is resolved only once. var app = angular.module('plunker',…
msapkal
  • 8,268
  • 2
  • 31
  • 48
6
votes
1 answer

Can I use AngularJS's $q outside an Angular component?

I am writing a browser app, and I have a file that creates an object and initializes it. The app is written in AngularJS, but the file in question is plain Javascript, outside the Angular ecosystem. I want to use promises in that file, but since…
FrontierPsycho
  • 743
  • 7
  • 25
5
votes
1 answer

Async Promise returns undefined or zone aware promise

When calling a function that returns a promise, comes back as undefined unless async operators are removed, then returns ZoneAwarePromise, but contains no data. I know the query returns data when the function executes, it however does not seem to…
DSMTurboAWD
  • 344
  • 1
  • 3
  • 16
5
votes
2 answers

Angular Wait for boolean function to finish

I am trying to fetch a list of users from my firestore database, and determine if the logged in user is an admin (i.e. he's in the list). This is my code: isAdmin(user: any): boolean { var col = this.afs.collection('admins'); var docRef =…
amitairos
  • 2,907
  • 11
  • 50
  • 84
5
votes
1 answer

How to use the axios library with AngularJS

Why axios callback changes are displayed in angularjs, without using $apply I was trying axios library on angularjs and I was surprised when I saw that the changes to $scope in the axios callback were detected by angular. I thought I had to call…
Ferran Maylinch
  • 10,919
  • 16
  • 85
  • 100
5
votes
3 answers

Is there an any method ordering when $q.all has multiple http call functions in Angularjs?

First of all, I am not good at angularjs. While I've been studying about $q, I faced a weird problem. When I use $q.all, I put $http in regular sequence expecting to get results in same order, but what I get was random results. See this and correct…
Canet Robern
  • 1,049
  • 2
  • 11
  • 28
5
votes
2 answers

Replacing $http with Fetch API

I'm replacing $http with Fetch API and got replaced $q with Promise API. Because of that, Angular didn't run digest cycles anymore, thus UI didn't render. To solve this problem I tried Zone.js and that seems to solve our problems partially.…
Gaui
  • 8,723
  • 16
  • 64
  • 91
5
votes
1 answer

Angular 1.6 $http.jsonp while using the google sheets API

The Angular 1.6's $http.jsonp does not play nice with the google sheets' API: I'm trying to fetch and then get my data from google sheets, with the following: var callback; app.controller("meetingsTable", function ($scope, $http, $sce) { var url =…
5
votes
1 answer

$q.all slower than sequential .then()?

I have some angular code that calls two separate backend services via $http.get. The backend is ASP.NET MVC 5. I call the services via $http.get, and since I need a response from both services before continuing, I wrap the returned promises in…
lcaaroe
  • 85
  • 6
5
votes
1 answer

Return of promise inside forEach

function getNamesById(nameIds) { var defer = $q.defer(); var result = []; nameIds.forEach(function (nameId) { account.getNameById(nameId).then(function (name) { result[nameId] = name; }); }); …
uromay
  • 329
  • 3
  • 11
5
votes
2 answers

ES6 Promise not Updating AngularJS DOM

I'm having trouble understanding angular components scope. If I do something like: function myComponent(){ this.data = 'Hello World'; } let myModule = angular.module('myModule', []); myModule.component('myComponent', { template:…
MinusFour
  • 13,913
  • 3
  • 30
  • 39