ionic + AngularJS error list item

0

I made a list in the ionic that returns some values, but when I click on the list to show these values completely, I can not recover ...

My controller:

    app.factory('services', ['$http', function($http) {
    var obj={};
    obj.getPessoas = function() { return $http.get('http://xxxx.com.br/conecta.php'); }
    return obj;
}]);

app.controller("pessoasCtrl", function($scope, services,$ionicScrollDelegate) {
    services.getPessoas().then( function(data) {
        $scope.pessoas = data.data;
    } )

    $scope.scrollTop = function() {
        $ionicScrollDelegate.scrollTop(true);   
    }; 
})

my app.js

.state('tab.chats', {
      url: '/chats',
      views: {
        'tab-chats': {
          templateUrl: 'templates/tab-chats.html',
          controller: 'pessoasCtrl'
        }
      }
    })
    .state('tab.chat-detail', {
      url: '/chats/:chatId',
      views: {
        'tab-chats': {
          templateUrl: 'templates/chat-detail.html',
          controller: 'pessoasCtrl'
        }
      }
    })

The call on the chats page:

<ion-item class="item-remove-animate item-avatar item-icon-right" ng-repeat="pessoa in pessoas" type="item-text-wrap" href="#/tab/chats/{{pessoa.DOU_CODIGO}}">
        <img ng-src="{{pessoa.face}}">
        <h2>{{pessoa.DOU_NOME}}</h2>
        <p>{{chat.DOU_ESPECIALIDADE}}</p>
        <i class="icon ion-chevron-right icon-accessory"></i>
      </ion-item>

And when I click on each line, I can not retrieve from chat-detail that it looks like this:

<ion-view view-title="{{pessoa.DOU_CODIGO}}">
  <ion-content class="padding">
    <img ng-src="{{pessoa.face}}" style="width: 64px; height: 64px">
    <p>
      {{pessoa.DOU_CODIGO}}
    </p>
  </ion-content>
</ion-view>
    
asked by anonymous 20.02.2016 / 13:10

1 answer

0

I did not see in your controller where you try to redeem the value of the passed ID, we usually use $stateParams.NomeDoparametro . Home I would do it as follows: I would take the href and call a function in ng-click

ng-click="selecionaPessoa(pessoa)"

This way you pass the entire selected object without having to select again. It's just adding the person to the scope within the function:

$scope.selecionaPessoa = function(pessoa){
    $scope.selecionado = pessoa;
};

In your HTML, just call {{selecionado.DOU_CODIGO}}

    
21.02.2016 / 16:23