angular-promise

how to execute the statement after promise is executed?

我的梦境 提交于 2019-12-12 05:26:08
问题 I have used the following directory in my template i want to change the model value of drop-down to id for it i have used as bellow <md-select flex class="md-select-form" ng-model="education.degree" placeholder="Degree" save-id id="education.degree_id" "> <md-option ng-value="degree" ng-repeat="degree in ['High School', 'Associates Degree', 'Bachelor Degree', 'Masters Degree', 'M.B.A', 'M.D', 'Ph.D', 'other']">{{degree}}</md-option> </md-select> .directory code .directive('saveId', function

AngularJS display a promise from Firebase

丶灬走出姿态 提交于 2019-12-12 04:38:29
问题 I am sure it is a simple problem, but since I work in angular for like 2 weeks now I can't seem to figure it out. I have this facebook login with firebase function: function FBLogin(){ var provider = new firebase.auth.FacebookAuthProvider(); firebase.auth().signInWithPopup(provider).then(function(result) { // This gives you a Facebook Access Token. You can use it to access the Facebook API. var token = result.credential.accessToken; // The signed-in user info. var user = result.user; console

Angular Table sorting does not work if i use a different api

前提是你 提交于 2019-12-12 04:31:57
问题 i took ngTable example from http://ng-table.com/#/loading/demo-external-array opened it in code pen and instead of "/data" i am using an api https://jsonplaceholder.typicode.com/posts and added isArray : true var Api = $resource("https://jsonplaceholder.typicode.com/posts", {}, { 'get': { method: 'GET', isArray: true} }); in html i took out all the columns and kept "id" column for simplicity it loads id column but searching sorting does not work. what is it that i am doing wrong ? changed pen

Assigning variable from a factory to a control doesn't work

一曲冷凌霜 提交于 2019-12-12 03:46:00
问题 My html is this: <body ng-controller="MainCtrl as ctrl" class="bodyContainer"> <div ng-repeat="stuff in ctrl.stuffies"> here </div> This is my controller: angular.module("AuthenticationApp", ["BaseApp"]) .controller("MainCtrl", ["$http", "$window", "BaseService", function($http, $window, BaseService) { var self = this; BaseService.fetch.stuffs(function() { self.stuffies = BaseService.stuffies; console.log(self.stuffies); self.cerrorMessages = BaseService.cerrorMessages; }); }]); And this is

Calling multiple $http services in a for loop from Angularjs controller and services javascript promise issue

我与影子孤独终老i 提交于 2019-12-12 03:27:00
问题 My Angularjs application have a controller and services java scripts. Services call WCF REST services using $http. I need to call multiple services in a For loop based on data in object used in For loop. Below is the scenario: "I want to upload few files to a folder on server and save file names to database. I have an array of file details that user selected to upload. I want to verify file names already in database (based on EntityId) then rename new file before uploading to server." So

angularjs not executing deferred promise using angular-socket-io

谁说我不能喝 提交于 2019-12-12 03:15:25
问题 After solving this issue I now have a new issue with angular halting inside a function that's waiting on a socket connection. Controller: .controller('myCtrl',function($scope, socket) { var sendMsg = function(msg) { socket.then(function(msg) { socket.emit('newMsg', msg); }); } //simplified example var msg = 'Hi Mom!'; sendMsg(msg); }); The problem is that socket.emit() never gets fired. If I remove socket.then() I will get an error socket.emit is not a function . We have to wait for socket to

$q promise not resolving

断了今生、忘了曾经 提交于 2019-12-12 02:51:13
问题 I can't figure out why this isn't resolving, any ideas? "resolve this" does print, but it never makes it back to the resolution of the promise in .then. var promise = wait(); promise.then(function(result){ console.log("wait returned - " + result); }); function wait(){ var deferred = $q.defer(); if(busy){ setTimeout(function(){ wait(); },500); } else { console.log("resolve this"); deferred.resolve("Wait is over."); } return deferred.promise; }; 回答1: Here's how it can be done instead: var

How return promise from multiple promises

大憨熊 提交于 2019-12-12 02:51:12
问题 I always in console see: teamsUpdated2 addUserToProjects deleteUserFromProjects but should bee in different order var result = teamService.addOrDeleteUser(userId, newTeams, deleteTeams); result.then(function () { console.log("teamsUpdated2"); }); function with multiple promises: var _addOrDeleteUser = function (userId, addToProjects, removeFromProjects) { var deferred = $q.defer(); var promises = []; promises.push(projectResource.addUserToProjects({ userId: userId }, addToProjects, function

How to correctly override `errResponse` which is passed to the `catch(function(errResponse){` function?

淺唱寂寞╮ 提交于 2019-12-12 02:38:47
问题 This is my controller: angular.module("AuthenticationApp", ["BaseApp"]) .controller("MainCtrl", ["$http", "$window", "BaseService", function($http, $window, BaseService) { var self = this; self.add = function() { BaseService.add.user(self.user) .catch(function(errorResponse) { self.cerrorMessages = errorResponse.data; }); }; This is my BaseApp / factory: angular.module("BaseApp", []) .config(['$httpProvider', function($httpProvider) { $httpProvider.defaults.xsrfCookieName = 'csrftoken';

How to use $q's constructor syntax with Angular $http's config.timeout?

不羁的心 提交于 2019-12-12 02:17:01
问题 Since Promise is now officially spec-ed and all, how do I convert the $q.defer() promise creation in the following snippet to use the $q(function (resolve, reject) {}) constructor syntax instead? // Cancel any ongoing $http request so that only the most recent $http // callback gets invoked var canceller; function getThing(id) { if (canceller) canceller.resolve(); canceller = $q.defer(); return $http.get('/api/things/' + id, { timeout: canceller.promise }); } (Fyi from $http docs: timeout is