2016-08-17 146 views
0
var requestOne = $http({ 
        method: 'POST', 
        url: $rootScope.apisrvr + 'user/user_signin', 
        data: { username: $scope.user.username, password: $scope.user.password }, 
       }); 

這個值是我的代碼,當我寫:console.log(requestOne);我得到: that獲得承諾對象的角度

我只想得到$$state/value/data/salt。但是,當我嘗試console.log(requestOne.$$state.value.data.salt);時,我收到錯誤TypeError: Cannot read property 'data' of undefined。我如何從這裏獲得salt

+0

Upvoted以下正確的答案,但總的來說還記得[任何以'$$'開頭的角度屬性都是_ private_](http://stackoverflow.com/questions/19338493/what-is-the-double-dollar-sign-used-for-in-angular)並且應該通過非私有方法訪問。 –

回答

1

requestOne是承諾變量本身,實際得到的結果,你需要一個.then調用添加到像這樣的承諾結束:

var requestOne = $http({ 
        method: 'POST', 
        url: $rootScope.apisrvr + 'user/user_signin', 
        data: { username: $scope.user.username, password: $scope.user.password }, 
       }).then(function(result){ 
        console.log(result); 
       });