2016-03-20 14 views
0

私はサーバーから返されたデータから大きな問題を抱えています。$ scope。$ apply関数は値を取り除き、データを操作できません。

データがサーバから返された:

angular.callbacks._0([{'Empresa':'Solução Informática','Email':'[email protected]','Filial':'1','Pontos':'504,23'},{'Empresa':'Keiken Sushi Bar e Restaurante ','Email':'[email protected]','Filial':'7','Pontos':'154,48'}]) 

アプリケーションからの印刷:コントローラから

print image

コード:

.controller('meusPontosCtrl', function($scope, $http, $localStorage,$ionicLoading, $timeout, $ionicPopup,$state,$stateParams,$window, MeusPontos,pontos) { 
    $scope.$on('$ionicView.enter', function(){ 
     $http.get('https://ssl-386475.uni5.net/bonus/ClienteIOS/meuspontos?id='+$localStorage.user.Id+'&callback=JSON_CALLBACK') 
     .success(function(response, status, headers, config){ 

      $ionicLoading.show({ 
       content: 'Carregando Dados', 
       animation: 'fade-in', 
       showBackdrop: true, 
       maxWidth: 200, 
       showDelay: 0 
      }); 
      $timeout(function() { 
       $ionicLoading.hide(); 
       //response = response.replace('angular.callbacks._0(','').replace(')','').replace('""',''); 
       $scope.$apply(function() { 
        $scope.pontos = response 
        console.log(response) 
       }) 
      }, 1000); 
     }) 
    }) 
}) 

HTMLのコードテンプレート:

<ion-view title="Meus Pontos"> 
<ion-content overflow-scroll="true" class="has-header" ng-controller="meusPontosCtrl"> 
    <ion-list> 
     <ion-item ng-repeat="item in pontos track by $index" type="item-text-wrap" data-ng-click="selecionado(item)" > 
      <img src="img/ic_action11.png" style="float:left; width:48px; heigth:48px; margin-right:24px"> 
      <h2>Creditos R$ {{item.Pontos}}</h2> 
      <p>{{item.Empresa}}</p> 
      <p>{{item.Email}}</p> 

     </ion-item> 
    </ion-list> 
</ion-content> 

+0

達成しようとしているのは正確ですか?レスポンスをJSON形式に変換しますか? – Dexter

答えて

0

あなたは$ HTTPサービスは、あなたのJSONを解析することをしたい場合は、サーバー(「アプリケーション/ JSON」)から正しいヘッダを送信する必要があります。

関連する問題