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 - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -