Search Posts

Category: callback

ng-show directive not working Angular (controllerAs issue)

I am building a single-page app with a timer and 2 buttons: 1st one shows up on initial state (onBreak=false), and handles a 25min-timer 2nd one shows up when the 1st timer is over (onBreak=true), and handles a 5min-timer Here is the HTML : <h1>{{ home.time | formattime }}</h1> <button type=”button” class=”btn btn-primary” ng-hide=”onBreak” ng-click=”home.workTimer()” ng-bind=”home.startOrResetWork”> </button> <button type=”button” class=”btn btn-primary” ng-show=”onBreak” ng-click=”home.breakTimer()” ng-bind=”home.startOrResetBreak”> </button> The controller : (function() { function HomeCtrl($interval) { var $ctrl […]

Why can’t I assign to a class variable from a $http success handler? [duplicate]

This question already has an answer here: How does the “this” keyword work? 19 answers For a project I’m working on, I’ve uncovered a situation that doesn’t make a whole lot of sense. I strongly suspect that, while I’m working in TypeScript, that my particular problem is due to a funny nuance of javascript, but I’m not sure how to prove it, or fix it. Background For the application I’m working on, I have a […]

AngularJS restangular post callback

I am using restangular with AngularJS, and I need to use some function, which will trigger callback function/promise after POST response. I tryed setResponseInterceptor which did not helped in this situation. I need to use this function to lock form from submission until response will come back to client, and then unlock it to future use. Do you know some magic for this? I am using this code, and want to fire custom function when […]

scope variable can not be setted inside service callback

I have the following code: svcUploadMidia.load(scope.TableId, scope.TableName, function(res) { scope.Midias =; for(var i = 0; i < scope.Midias.length; i++) { scope.Midias[i].conteudoBase64 = “data:image/png;base64,” + scope.Midias[i].conteudoBase64; } }, function(err) { errorHandler(err); }); This code is inside a directive and is called by another directive. But all changes made inside the svcUploadMidia.load callback is not setted in the directive scope.Midias and the ng-repeat in the html still empty. Someone know how can I fix it? Source: AngularJS

Call back function returns an object which cannot be accessed ,it only appears in console.log in angular

I have followed the below git hub link that has a service called and using this service in login function as (googleService) function login () { googleService.login().then(function (data) { $‘/googleSignIn’,data) .then(function (data) { // window.location.reload(); }, function (err) { if ( { toastr.error(; return; } }); }, function (err) { console.log(‘Failed: ‘ + err); }); }; The data object can be seen in console.log statment only when I click the arrow beside it and […]

How to use the callback on the basis of selection in Angular js?

I am trying to design a simple game application. There is a list of games available and there is a list of selected game. My intention is to show whatever the games is not selected in the modal and ask user whether they want to add it or not. Once they skim all the available games we can get the final selection of whatever the games selected and not selected.I am Stuck at one point, […]

Nodejs callback response not working as expected

I’m trying to authenticate a user based on values entered in a given form. However, after using res.send(), the function at AngularJS controller is not able to correctly redirect user even if the password and username are correct. Am I handling the callbacks correctly? Controller <script> var app = angular.module(‘myApp’, []); app.controller(“loginController”, function($scope,$http) { $scope.sub = function() { var config = { headers : { ‘Content-Type’: ‘application/x-www-form- urlencoded;charset=utf-8;’ } } $‘/login’, { data:{ username: $scope.username, […]