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
Post a Comment