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

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -