I have a big issue from the data I return from the server, the $scope.$apply function strips the value and I can't manipulate my data.
The data returned from the server:
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'}])
The print from the app:
The code from controller:
.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);
})
})
})
The code from the html template:
<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>
If you want that the $http service parse your json, you have to send the correct header from your server ("application/json").