을 반환하지 않습니다AngularJS와이 내도이다 (긴 변수와 함수 이름에 대한 죄송합니다) defer.promise
<tr ng-repeat="passation in passations " >
<td ng-init=" passation.stats_quota_campagnes = get_stats_quota_campagnes(passation)">{{passation.stats_quota_campagnes}}</div></td>
</tr>
이 결과를 반환하도록되어 내 AngularJS와 함수이다 :
$scope.get_stats_quota_campagnes = function(passation){
var defer = $q.defer();
$http.post('backend/backend.php?action=stats_quota_campagnes',{'id_passation':passation.id_passation})
.success(function(data){
console.log(data);
defer.resolve(data);
});
return defer.promise;
}
console.log (data); 나는 많은 것들을 시도했습니다
Object { 0: "401", Quota: "401" }
하지만,하지만 내보기에 할당량 값을 얻을 전혀없는이 '메신저 끝에 다시 PHP에서 정확한 데이터를 얻기를 보여! defer.promise 변수는 항상 비어 있습니다. 이유를 모르겠습니다. 내가 뭘 할 수 있니? 을 console.log 그것이 오른쪽 변수는 $의 HTTP에서 오는 작동하고 있음을 보여주고 있지만, 값 대신
{}
를하지만보기 '아무튼 :
내보기에, 실제로이 ISEE t 업데이트. $ apply()에 대해 들었지만 사용 방법을 모른다.
ng-repeat, ng-repeat의 각 객체에 대해 함수를 호출해야하기 때문에 변수 이름을 어떻게 알 수 있습니까? – user7370387
@nick 'passation'을 매개 변수로 사용합니다. '.success' 콜백 각도는 검색된 데이터를'passation' 객체에 넣습니다. 그러므로 view에서'passation.stats_quota_campagnes'를 사용할 수 있습니다. – devqon
$ scope.myVariableUsedInView는 ng-repeat 루프이기 때문에 존재하지 않습니다. ng-repeat 중에 업데이트해야하는 여러 passation 변수가 있습니다. $ scope 사용법을 볼 수 없습니다.myVariableUsedInView = data – user7370387