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
9
votes
1 answer

How convert Angular promise to jquery deferred object

I want to return promises from my module/sdk to non-angular javascript. For example if I'm returning promise to a jquery, I should be probably sending jquery deferred object. How can I convert an Angular promise to a jquery promise/deferred obj. Any…
phani
  • 1,134
  • 1
  • 11
  • 24
9
votes
2 answers

AngularJS : $q -> deferred API order of things (lifecycle) AND who invokes digest?

The $q service is very powerful in angularjs and make our life easier with asynchronous code. I am new to angular but using deferred API is not very new to me. I must say that I completely ok with the How to use part of documentation + there are…
arty
  • 1,276
  • 15
  • 24
8
votes
1 answer

Difference between Promise, Promise/A and Promise/A+

I've read the Promise/A+ specification, but as far as I understand there are also such things as Promise/A and Promise. What is the difference between all of them? Are Promise and Promise/A specifications as well? If so, what's the difference? Sorry…
Dmitry Senkovich
  • 5,521
  • 8
  • 37
  • 74
8
votes
2 answers

Angular - Is .finally() Called At the End of Every Path in a Chained Promise Decision Tree?

I have the following chained sequence of promises: $scope.promisesInProgress = true myService.myFirstPromise(id) .then(function(data){ $scope.firstResponse = data; return myService.mySecondPromise(id); }) …
Lloyd Banks
  • 35,740
  • 58
  • 156
  • 248
8
votes
2 answers

AngularJS : returning data from service to controller

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',…
8
votes
1 answer

Angular: Returning a $q.defer().promise instead of an $http promise

Watching a lot of Egghead.io videos, I noticed that a common pattern is to return a custom promise and resolve it in the callbacks. .factory('myFact', function($q, $http) { return { getData: function() { var deferred =…
diplosaurus
  • 2,538
  • 5
  • 25
  • 53
8
votes
2 answers

unit testing angularjs $q.all - promise never completes

I'm trying to test a service that I build which uses Angular's $q implementation of Promises. I'm using a combination of Karma, Mocha, Chai, Sinon, Sinon Chai and Chai as Promised. All the tests that I wrote and return promises are passing but the…
Roland
  • 9,321
  • 17
  • 79
  • 135
8
votes
1 answer

Create an AngularJS promise with no return value

I am using $q to wrap a promise around a legacy callback. However, the existing callback doesn't have a value to return. It takes a success function with no parameters. angular.module('MyModule').service('MyService', function() { function…
metacubed
  • 7,031
  • 6
  • 36
  • 65
8
votes
1 answer

solving $rootScope:infdig Infinite $digest Loop

I get the basic idea of the infinite digest loop and how it happens, but I'm running into the problem. Here is a fiddle demonstrating my code and problem: http://jsfiddle.net/eS5e5/1/ In the jsfiddle console you'll see the infinite digest…
lostdorje
  • 6,150
  • 9
  • 44
  • 86
8
votes
2 answers

Resolving a deferred using Angular's $q.when() with a reason

I want to use $q.when() to wrap some non-promise callbacks. But, I can't figure out how to resolve the promise from within the callback. What do I do inside the anonymous function to force $q.when() to resolve with my reason? promises = $q.when( …
willoller
  • 7,106
  • 1
  • 35
  • 63
7
votes
6 answers

Benefits of Observable with Http in Angular

From here: https://stackoverflow.com/a/40135509/462608 First this answer describes how Observables are helpful in preventing same repeated requests to the server and how we can pause between many requests so that the server doesn't get…
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
7
votes
1 answer

How to access class variable inside Promise then() function?

I'm working on a Angular4 + PHP website, where i send HTTP requests to the server using Promise, since i want my application to perform routing according to the response of the server. I want to access a class variable inside the then() but it…
Suroor Ahmmad
  • 1,110
  • 4
  • 23
  • 33
7
votes
1 answer

Drag and drop image upload, angular 4

I created a drag and drop fake upload service. I can log the width and height of the picture as well as the url. However the image is not uploading. The problem is that the 'img' in my upload function is undefined if I want to log that. How can I…
7
votes
1 answer

ASP.NET Core WebApi return error message to AngularJS $http promise

I would like to return exception message to the AngularJS UI. As a back-end I use ASP.NET Core Web Api controller: [Route("api/cars/{carNumber}")] public string Get(string carNumber) { var jsonHttpResponse =…
Alex
  • 842
  • 11
  • 33
7
votes
1 answer

Returning an AngularJS $q promise with TypeScript

I have a service that wraps $http with my functions returning a deferred object. My interface: export interface MyServiceScope { get: ng.IPromise<{}>; } My class: export class MyService implements MyServiceScope { static $inject =…
charcoalhobo
  • 73
  • 1
  • 1
  • 3