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
0
votes
2 answers

Angular.JS loop keeps running while a service call inside the loop is waiting for promise

"AddDistance" is an insert to DB function, the problem is that hash[k][2] value jumps forward with the loop while "distance"(the service promise) is still waiting, and as result i insert wrong row to my DB. how do i hold the loop from jumping to the…
tomersss2
  • 135
  • 12
0
votes
1 answer

'Promise' is not assignable to type 'Promise' error

I am new to Angular 2, and Angular as well, and I am running into this issue related to promises. I have this file name module.service.ts import { Injectable } from '@angular/core'; import { Module } from './module.entity'; @Injectable() export…
Jean-Baptiste
  • 1,552
  • 1
  • 19
  • 33
0
votes
1 answer

Angular $http.get success handler not called in Jasmine unit test

I have a very basic factory service that I would like to unit test. I have tried $rootScope.$digest() and $rootScope.$apply() before the expect statements and neither the success or failure handlers are being called at all in the unit test - they…
anjunatl
  • 1,027
  • 2
  • 11
  • 24
0
votes
0 answers

Is there any way to cancel all the requests in $q.all()?

When a user switch a state when another state is being loaded, I am destroying the controller of the previous state. But there are still some promises in the previous state that are yet to be resolved. So even after destroying the state controller,…
subs
  • 2,189
  • 12
  • 35
  • 59
0
votes
1 answer

AngularJs promise returns undefined

I'm trying to use the login function of my AuthService factory from my AuthLoginController controller. The problem is that when the User.login function is executed with a wrong email and password, the console.log() returns false which is what I…
Thomas Fournet
  • 660
  • 1
  • 6
  • 23
0
votes
1 answer

Waiting for modal promise in Angular error interceptor

I am using a promise to query a service from my web-app. If the token is invalid, I now want to ask the user for the credentials using a modal, query a new token from the backend, rerun the failed request and return into the success block of the…
manima
  • 21
  • 2
0
votes
1 answer

How can I update my view model from chained promises?

I'm quite new to promises. I have a hard time trying to update an object used in my view from 2 chained promises : function Test($resource, FC, UserDetailsService) { 'ngInject'; var self = this; self.data = { }; function…
redAce
  • 1,558
  • 4
  • 14
  • 24
0
votes
0 answers

Angular2 - AsyncValidator dependent on parallel call

I'm having an issue with AsyncValidators. Normally the promise being resolved is dependent upon code being called by the promise itself, but what about when the code is being called from outside and the promise has to listen for it? I'm not sure I'm…
0
votes
1 answer

Scope variable value is undefined outside resource service in angularjs

I have created angularJs factory service to dealing with REST calls.Service is worked fine.I have some cases that i need to set values in to $scope.variable and access them in outside of resource service.But i got undefined. I wrapped them inside…
gihan-maduranga
  • 4,381
  • 5
  • 41
  • 74
0
votes
1 answer

Using function with ng-repeat causing infinite digest loop

I have the following piece of code. https://plnkr.co/edit/Tt7sWW06GG08tdJu72Fg?p=preview. Please expand the window fully to see the whole view. I have categories and sub-categories to display in a navbar as shown in the above plunkr. Each category…
mhaseeb
  • 1,739
  • 2
  • 12
  • 24
0
votes
1 answer

Get Button value in onRemoving callback

I am using $mdDialog service of AngularMaterial. Here's the sample code that I am using - var highlighter = {}; $mdDialog.show({ templateUrl: 'sample.html', parent: angular.element(document.body), clickOutsideToClose: true, …
0xC0DED00D
  • 19,522
  • 20
  • 117
  • 184
0
votes
0 answers

How to implement a stateful proxy in angular js?

export default function appState($q, $rootScope, StateService, DateService, filterState) { var state = { dates: [], type: StateType.NOTLOADED }; function _stateChange(type) { if(type instanceof StateType) { …
0
votes
1 answer

AngularJS promise through tow loops

Have some trouble with Angular promise between two loops... First loop walk through an array of value, and for each value, make a PouchDB Query to retrieve some datas. Finally, would like to return to controller a JSON Object that would look like…
Jean-Luc Aubert
  • 620
  • 5
  • 19
0
votes
1 answer

Angular Components does not work with Promise and Service

I have a really strange problem with Angular Components calling a service. For example, i have a simple service with some mockup data as an array inside. The i add two methods, one synchron and one asynchron which returns a promise (if i correct…
vandango
  • 567
  • 1
  • 4
  • 13
0
votes
2 answers

Chaining promises when one of the promises is executed conditionally

I have two promises which are chained as below , var promise1; var promise2 = promise1.then(function() { }); Now I have a condition that promise1 will be executed based on a condition i.e if(userid == 123) { promise1 should execute. } How do I…
VishnuNair
  • 121
  • 4
  • 12