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

PHP Error "Undefined index" -

C# List<> to xml -

javascript - Concatenate two fields in one in CRM 2011 -