angular-promise

AngularFire V1.2 $firebaseArray() $loaded() only called once [duplicate]

与世无争的帅哥 提交于 2020-01-05 06:49:30
问题 This question already has an answer here : $on loaded fires once for new references AngularFire 0.5.0 (1 answer) Closed last year . I am using AngularFire and promises on arrays ( $loaded() on firebaseArray() ). Currently, I'm using the following code: Problem : I go to page1, the data is loaded and all fine. Go to page 2 and come back to page1. Now the $loaded() doesn't work until I do a full page refresh. How do I fix this problem? app.factory('Items', ['FBURL', '$firebaseArray', function

AngularJs get employee from factory

若如初见. 提交于 2020-01-04 06:09:13
问题 I've got a employeeController and a employeeFactory in the employeeFactory I receive an employee like this: function employeeFactory(authenticationFactory,requestFactory,GLOBALS) { var factory = {}; var vm = this; vm.employee = {}; factory.getEmployee = function(id) { data = {"api_token": authenticationFactory.getToken()}; url = GLOBALS.url + 'show/employee/' + id; requestFactory.post(url, data) .then(function (response) { return vm.employee = response.data.result.Employee; }, function () {

AngularJs get employee from factory

China☆狼群 提交于 2020-01-04 06:09:03
问题 I've got a employeeController and a employeeFactory in the employeeFactory I receive an employee like this: function employeeFactory(authenticationFactory,requestFactory,GLOBALS) { var factory = {}; var vm = this; vm.employee = {}; factory.getEmployee = function(id) { data = {"api_token": authenticationFactory.getToken()}; url = GLOBALS.url + 'show/employee/' + id; requestFactory.post(url, data) .then(function (response) { return vm.employee = response.data.result.Employee; }, function () {

Is Ionic Framework resolveLocalFileSystemURL Asynchronous?

若如初见. 提交于 2020-01-03 21:09:41
问题 I am calling a function from my AngularJS controller. When the function completes execution, I would like to print the result after the function call. This code is inside the controller, which is called on-tap //count the number of files inside a directory var count = countDir(cordova.file.dataDirectory +'/Images/'); console.log('Hello '); console.log('Count of directory '+count); Here is the countDir function. This function finds the number of files in a directory and then returns the count

AngularJs promise in forEach

别等时光非礼了梦想. 提交于 2020-01-03 19:17:06
问题 I have method for getting data from server. And I use it in foreach, and after it need bind him to $scope variable. Like this: var qualityMix = []; var engagementMix = []; angular.forEach(versions, function (versions) { qualityMix.push(qualityScoreByTimeWithAppVerPromise(versions.version)); engagementMix.push(engagementByTimeWithAppVerPromise(versions.version)); }); $scope.qualityScoreByTimeMix = function () { return $timeout(function () { return $q.all(qualityMix).then(function (data) {

Angularjs custom directive using http promise not binding with template

守給你的承諾、 提交于 2020-01-03 02:25:30
问题 I am new to angularjs and want to add new feature in existing code. But code is not working as expected. I know i am not doing it the right way. Please correct me where is the mistake. I don't know why controller is not used but directive is used in this approach? Here is my custom service and custom directive directive code. Service code: angular.module("quickquiz-builder").service("SettingsService", function ($http, $q) { return { /* Return deffered promise response */ get: function() { var

How to deal the data when the promise in a loop?

余生颓废 提交于 2020-01-02 00:33:06
问题 This is my way: var activeArr = []; var activeDate = []; var day = (endDate - startDate) / (24 * 60 * 60 * 1000); for (var i = 1; i < day + 1; i++) { activeDate.push(endDate - (24 * 60 * 60 * 1000) * i); var start = endDate - (24 * 60 * 60 * 1000) * i; var end = endDate - (24 * 60 * 60 * 1000) * (i - 1); statisService.getRegStatis(start, end).then(function(data) { activeArr.push(data); if(activeArr.length == day){ var active = []; for(var j=0;j<activeArr.length;j++){ var obj = {}; obj.date =

Angular2 Observable - how to wait for all function calls in a loop to end before proceeding?

人走茶凉 提交于 2019-12-31 17:49:33
问题 I am trying to improve my knowledge of Angular2 by migrating an application currently written in Angular1 One feature in particular has me stumped. I am trying to replicate a feature where a calling function waits to proceed until the function it is calling has completed a loop of promises. In angular one the function I am calling looks basically like this: this.processStuff = function( inputarray, parentnodeid ) { var promises = []; var _self = this; angular.forEach( inputarray , function(

ui-router: async data in templateUrl function

删除回忆录丶 提交于 2019-12-31 05:57:37
问题 I've run into quite a novel problem with ui router. I'm basically trying to query my API for a template url, which is stored and returned as a Resource object. The problem, is it seems that the templateUrl function is returning as undefined. My code is as follows: (function() { 'use strict'; angular.module('myApp') .config(function ($stateProvider, PageProvider, $httpProvider) { $stateProvider .state('core', { abstract: true, templateUrl: 'app/core/core.index.html', controller:

ui-router: async data in templateUrl function

此生再无相见时 提交于 2019-12-31 05:56:50
问题 I've run into quite a novel problem with ui router. I'm basically trying to query my API for a template url, which is stored and returned as a Resource object. The problem, is it seems that the templateUrl function is returning as undefined. My code is as follows: (function() { 'use strict'; angular.module('myApp') .config(function ($stateProvider, PageProvider, $httpProvider) { $stateProvider .state('core', { abstract: true, templateUrl: 'app/core/core.index.html', controller: