Tagged Questions
2
votes
3answers
26 views
Promise chain success is executed after first one returns error
i have a promise chain, in which the first promise causes a failure, but even then the second promise is getting executed successfully whereas as expected that should have failed...
PLUNKER LINK
...
0
votes
1answer
20 views
How to use factory/service which makes an Ajax request in ui-router resolve?
I am using the ui-router(http://angular-ui.github.io/ui-router/site/#/api/ui.router) solution for a form wizard and my state configuration looks like the following:
$stateProvider
...
-1
votes
2answers
91 views
Rewrite code using promises
I have the following code that causes the two call to Webtrends to be cancelled (ie these two calls did not give a http 200 but a cancelled message in the network tab of the browser) when I call it
...
0
votes
2answers
56 views
Convert a simple ajax call to use promise jQuery/AngularJS
I have this general method to use AJAX calls in a app:
function doAjaxCommand(url, type, async, params, successCallback, failCallback) {
$.ajax({
url: url,
type: type,
...
1
vote
3answers
41 views
Angular ng-repeat view does not update after a search
I'm trying to use a service call to update a results array that then gets used in an ng-repeat. On a form submit I call the necessary service and hookup my callbacks via .then() on the promise object. ...
0
votes
3answers
50 views
Turn for loop to async
I have something like this in frontend Javascript:
function myfunc() {
for (var i=0; i<=1000000000; i++)
// Do something
return data;
}
I want to call myfunc() in an async way so that I ...
0
votes
1answer
43 views
What should my services return to controllers?
I'm slowly learning Angular and I'm wondering if my singletons (services & factories) should return a promise object (containing the required data) to my controller or if all promises should be ...
0
votes
1answer
32 views
AngularJS nesting promises issues
I need your help to solve this problem , in fact, I'm don'yet understand how to retrieve promise result in some nesting promise, bellow is my code
// service
mainApp.factory('myService', ...
3
votes
2answers
39 views
angular's $q.reject() vs deferred.reject()
I'm trying to get a handle on the angular $q service and its related objects and apis. When I look at the objects in my console I see:
var deferred = $q.defer()
...(and then from console ...
0
votes
2answers
60 views
Abort AngularJS $http request, deeply nested in multiple service calls
I'm using a deferred promise to abort a $http request (like explained in this post).
However, I'm unsure of how I should propagate the abort() function added at the root level. Everytime I call ...
0
votes
2answers
87 views
Chain promises with AngularJS
I have a service called paymentStrategy that get injected in my controller.
$scope.buy = function() {
paymentStrategy.buy()
.then(function(response) {
}
}
This buy method from ...
0
votes
0answers
36 views
Reject Angularjs resource promises
So I'm working on a Angularjs based mobile app. When a user taps on each of the tabs along the bottom a new route is called which is loading the partial and controller.
In my controllers I often ...
1
vote
1answer
45 views
Passing scope data into $http function
I'm constructing elements from metadata and i need to set a calculated class for each element.
This is what I currently do,
var promisses =_.map(templates, function (tmpl) {
return ...
0
votes
2answers
38 views
AngularJS promises don't execute in order
I can’t get my head around some of the promises. They work fine in some instances of my app, but in some they just never work.
In my controller, I have the following command:
...
2
votes
2answers
31 views
AngularJS update view with service/model changes using $q promises
I'm trying to load data from a service and update the view using $q, but it's not working. It works if I put the http call inside the controller, but I'd prefer it be part of the service.
Any ...
0
votes
1answer
38 views
Chaining async tasks on Angular
Goal
What i am doing is chaining various asynchronous tasks that depend on the response of the previous ones to finally get an Array of objects that wrap all the responses to be used in the $scope. I ...
0
votes
2answers
44 views
How do I access $q (promise service) from this angular ajax service
I have the following angular service:
app.factory('myFactory', function ($http) {
var returnedObject = {
getA: function() { return $http.get('../A'); },
getB: function() { return ...
0
votes
0answers
19 views
Promise that is resolved with debug
I am in an angular project.
What is happening is that I have a promise in the resolve of a route that isn't resolved but if I am debugging the application the promise is resolved.
Someone with some ...
1
vote
2answers
40 views
Why is a $q promise returning an $http promise as a payload?
I have a promise chain which has to call $http partway down the chain and pass the resulting promise to the next handler. The problem is my .then() success function appears to be wrapping the ...
0
votes
1answer
22 views
Conditional based on the results returned by $resource promise
I am calling my api through angularjs and returning a list of 'reports' to angular through the $resource promise. Based on whether any results were returned I want to either show a modal with the ...
2
votes
1answer
33 views
AngularJS create deferred function
I'm new to angularJS and still have some difficulties with promises... I have the following function:
removeMultipleAttachments: function(docid, rev, attachmentIDs) {
var p = $q.when();
...
4
votes
3answers
86 views
Get state of Angular deferred?
With jQuery deferreds I'm used to be able to check the current state like this:
var defer = $.Deferred();
defer.state(); //Returns the state of the deferred, eg 'resolved'
Is there a way to do the ...
0
votes
0answers
31 views
promises not getting resolved while testing directive using jasmine
I am currently testing a custom directive which uses promises.
The structure of the first part of code segment of the directive is as follows:
angular.module('app').directive('simpleMock', [
'$q',
...
1
vote
1answer
44 views
reset the $q resolve state in angularjs
I have a service that runs an ajax query which upon success forwards that to a second function to parse the response into an object. The function that is initially called returns a promise using the ...
2
votes
1answer
65 views
NodeJS - Deferred function inside a loop
I have a conceptual problem with NodeJS... I need to call a deferred function within a loop and use the response for the next iteration. How can I do that without blocking? Here is what I did but of ...
4
votes
1answer
197 views
How do I use Bluebird with Angular?
I tried using Angular with Bluebird promises:
HTML:
<body ng-app="HelloApp">
<div ng-controller="HomeController">{{name}} {{also}}</div>
</body>
JS:
// javascript
var ...
1
vote
1answer
56 views
Chaining Promises with Failure
Looking at this blog's post handling of promises, I modified the failure example:
var myApp = angular.module('myApp',[]);
myApp.controller("MyCtrl", function ($q, $scope) {
(function() {
...
-1
votes
1answer
63 views
Repeat .then() as often as there are items [duplicate]
Suppose I have an array var numbers = [0, 1, 2] and an $http request.
I want to chain as many .then() functions after the $http.get() as there are items in numbers. So I want code like
//for each ...
0
votes
1answer
27 views
Error passing arguements between promises in AngularJS
I’m building a promise chain which contains four functions. The purpose of the promise is to make a few API calls. Each API call affects the following one, and some require multiple arguments.
The ...
-2
votes
2answers
26 views
Angularjs and Requirejs promises
I use RequireJS with AngularJS for lazy loading. it works correctly but my view appear before fetching data from database. what is the problem? How can I solve this problem?
0
votes
0answers
25 views
AngularJS $timeout freezes during refresh No New Data Uploaded
I'm trying to make a simple feed where you traditionally pull down to refresh latest content, and scroll down to view old content.
THE PROBLEM: I want to delay for 1 second, push content to the front ...
0
votes
1answer
47 views
synchronous for loop with promises
I have the following function that works but not as I want it to since each iteration needs the results of the iteration before.
There are plenty of similar questions but I'm finding it hard to ...
1
vote
1answer
55 views
AngularJS handle rejected response with UI-Router
I have a Service which wraps my API calls in Angular:
var ConcernService = {
list: function (items_url) {
var defer = $q.defer();
$http({method: 'GET',
url: api_url ...
0
votes
1answer
30 views
Track progress of facebook graph api requests
I am willing to track the progress of the queryng from facebook's graph api. I have this promise in an angular service
getPosts: function() {
var deferred = $q.defer();
FB.api(
...
0
votes
3answers
41 views
AngularJS promise and prevent redundant async calls
I have a wcf service method that gets some data and I call it using Microsoft Ajax library.
To share this data I create a dataService, and many controllers use this service.
I want every controller ...
1
vote
0answers
29 views
Jasmine: $q-promise does not get resolved nor rejected [duplicate]
I got a problem when testing my angular service with jasmine 2.0
I have a method in my service, returning a promise.
Now I would like to test, that this method returns or rejects this promise.
I ...
1
vote
1answer
82 views
AngularJS $rootScope loses value unless I use promise (trigger.io AJAX request)
So this is quite weird. $rootScope is getting set correctly within a function, but then loses its value. I can only keep the value if I use a promise. (!?)
I am using a trigger.io (Forge) AJAX ...
1
vote
1answer
45 views
AngularJS executing promises in turn
I need to be able to execute a series of asynchronous events in turn, but the execution of each depends on the result of the last. Is there anyway to achieve this dynamically? Consider the following ...
1
vote
0answers
95 views
Angular js - $routeProvider - how to get it to resolve on routeChangeStart
I'm reading the Angular documentation for $routeProvider and I the parameters say:
resolve - {Object.=} - An optional map of
dependencies which should be injected into the controller. If any of
...
2
votes
1answer
44 views
Angular promises in $q.all are not being rejected
Background
I have a hierarchy of entities that looks like (Manufacturer -> Vehicle Type -> Vehicle Model -> Vehicle Submodel). Each manufacturer has multiple vehicle types, each vehicle type ...
0
votes
1answer
33 views
angular ui router passing just the data from $http get
resolve: {
document: function ($stateParams, specialGet, $http) {
var id = $stateParams.id
return specialGet(id)
},
},
.factory('specialGet', function (Pusher, $q, $http) {
return ...
1
vote
3answers
49 views
How to convert simple $http with callback to use promises
I'm trying to wrap my head around promises in angular and i have the example below that I'd like to convert to use promises so hopefully it will help me go "Ah ha!".
All the examples that I find on ...
1
vote
3answers
33 views
Cache result of parse.com promise in angular app
I'd like my objects to cache the result of some network requests and answer the cached value instead of doing a new request. This answer here done using angular promises looks a lot like what I'm ...
0
votes
1answer
29 views
Missing image handle with promise
I would like to load tons on images in the background from urls, and if one of them isn't available, don't load, just throw an error message. I created a service for this in AngularJS, and my problem ...
0
votes
2answers
39 views
Angular JS: Fetching the data from server before the view has been shown to the user
My config looks like the following:
app.config(function ($routeProvider) {
$routeProvider
...
.when('/project/:slug', {
templateUrl: 'partials/plaintasks-part.php',
...
2
votes
1answer
72 views
Count pending $q promises in angularjs
I'm working on a complex angularjs app. Complex meaning single view can have several different data sources being queried from different places of the code, e.g. page-part controller or directive ...
0
votes
1answer
84 views
Angular promise (of a promise?). Or how do I chain a .then after an $http.success in angular
I got a service in Angular:
App.factory('AuthService', function ($q, $http, CredentialStorage) {
var _endpoint = 'http://localhost:3000';
return {
login: function (credentials) {
return ...
1
vote
2answers
53 views
Transforming callbacks into promises
I'm asking the server for a piece of information in two different ways. Without promises it could work as follows
function callback(someData) {
displaySomeData();
}
request1(user.name, ...
1
vote
1answer
40 views
Angularjs: $resource chaning with a $http call
How could I compare the result of these different calls? The url, and the fruit list stored in a different json file, and I would compare them before I send them as a promise. They should wait each ...
4
votes
1answer
50 views
AngularJS: Searching an Array returned from a promise in a service
I have an AngularJS service, it fetches an array with JSON objects from a server.
In the service, i need a function "getElementByID(ID)" from the list the service fetched. (or get Element by XY)
...