FAQ Database Discussion Community


How to make synchronous AJAX requests in AngularJS controller

javascript,jquery,ajax,angularjs,angularjs-promise
I've been told that $http in Angular is asynchronous. However, for some purpose, I need to make sequential AJAX requests. I want to read all the files from a file list, and then get the number from all those files. For example: content of "fileNames": file1 file2 content of "file1":...

Return Object Outside of Function

javascript,angularjs,firebase,promise,angularjs-promise
I'm trying to return an object outside of a function. I'm using an Angular JS promise to log the availableProviders when they've been loaded, which is logging correctly to my console. function getServiceProviders(serviceId) { var serviceProviders = ref.child('services').child(serviceId).child('providers'); var providers = ref.child('providers'); serviceProviders.on('value', function(snapshot) { // on services.serviceId.providers var availableProviders...

Make multiple calls to $resource after the return of another one in AngularJS 1.4

angularjs,angularjs-resource,angularjs-promise
I'm currently trying to find a kind of best practice to make multiple calls to $resource in function of the return of a first one. Consider the following schema : we have a database of authors, that have books, that have multiples tags (sf,thriller,horror,...). angular.module('myApp',[ngResource]) .controller('myCtrl',['$scope', function($scope){ $scope.results = [];...

Data not displaying in html file because of some angularjs issue

angularjs,mongodb,spring-mvc,angularjs-scope,angularjs-promise
I have to display some data from mongodb database using spring and angularjs. Data is being fetched to service.js method of angular js but its not displaying into html file as its not returning to controller. UserNotification.html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html;...

Parse query then state change after resolve

angularjs,parse.com,angularjs-factory,angularjs-ui-router,angularjs-promise
I have a factory defined to make a parse call that resolves upon completion. .factory('currentRestaurantService', ['$rootScope', '$q', function($scope, $q) { return { getCurrentRestaurant: function() { var defer = $q.defer(); // Create a deferring object $scope.currentUser = Parse.User.current(); // Get restaurant for user var restaurantObject = Parse.Object.extend("Restaurant"); var query = new...

Calling additional service functions after a resolved promise in Angular

javascript,angularjs,angularjs-scope,angularjs-service,angularjs-promise
In Angular I have a service to access the google contacts api, then store all my contacts into variable (StorageVar) to be analyzed by other functions in the service. Should I call one of the analysis functions before getting the data from the API, I want to call the getAPI...

success and error function in the controller for a service

javascript,angularjs,angularjs-service,angularjs-http,angularjs-promise
I have the following code in a service and I am calling fetchData function from the controller. Service app.service("geturl", function($http) { urllist = []; geturl.fetchData = function() { var data = []; for (i = 0; i < urllist.length; i++) { (function(index) { return $http.get(geturl.urllist[index], { timeout: 8000 }) .then(function(response)...