http - Angularjs $httpd assign variable onSuccess to $scope empty -


i have controller:

.controller('mycontroller', ['$scope','$http', function ($scope,$http,) {      $scope.saveit = function () {         $scope.key = '';         $http.get('/gethash',{"key": $scope.key})         .success(function(response, status, headers, config){             $scope.key = response.key;         });     }      console.log ($scope.key) // key empty } 

why @ end $scope.key empty?

it won't set until call saveit(), won't have done yet when log statement executed. you've defined function sets key, haven't invoked it.


Comments

Popular posts from this blog

How to logout from a login page in asp.net -

Stack level too deep error after upgrade to rails 3.2 and ruby 1.9.3 -