2015-05-06 55 views
-1

我已經在利用api調用之外的$ promise值觸發了,但是我得到了未定義的值。請幫助我如何獲得外部價值。

getPeople($scope.selectedId).fetch({ 
      }).$promise.then(
       function (value) { 
        $scope.peopledata = value.data[0]; 
        console.info($scope.peopledata); // here I can get data 
       }, 
       function (err) { 
       }); 

console.info($scope.peopledata); //但在這裏,我得到未定義

我怎樣才能得到的數據之外?

+2

如果你登錄'value.data'你得到了什麼 –

+2

你等待承諾解決之前,你的'console.log'承諾之外(這就是承諾)? – ProblemsOfSumit

+0

總之,在一個承諾你geting $ scope.peopledata,但外面你還沒有定義?我理解正確嗎? – Beri

回答