Does not read the backend in View - Ionic + AngularJs:

1

I can read my backend, but I can not show the data in my view, what can I be doing wrong?

In my controller I did the following, and I asked to read my backend:

.controller("restaurantesCtrl", function($scope,$state,$ionicScrollDelegate,$http,$stateParams,$timeout,$ionicLoading,$ionicPopup,$ionicPopover,$ionicSlideBoxDelegate,$ionicHistory,ionicMaterialInk,ionicMaterialMotion){


$scope.itens = [];

$http.get('http://nhac.esy.es/lista_restaurantes.php')
.success(function(itens){
    $scope.itens = itens;
    console.log("leu");  
    console.log($scope.itens = itens);
})
.error(function(erro){
   console.log(erro);
    console.log("não leu")
});

In my view I did the following:

    <ion-view view-title="Restaurantes" hide-nav-bar="false" >
    <ion-content delegate-handle="top" lazy-scroll  id="page-restaurantes" class="has-header page-restaurantes" >

        <ion-refresher pulling-text="Role para atualizar..."  on-refresh="doRefresh()"></ion-refresher>
        <ion-list class="card list">
            <div class="item item-input">
                <i class="icon ion-search placeholder-icon"></i>
                <input type="search" ng-model="q" placeholder="Procurar" aria-label="filter promoess" />
            </div>
        </ion-list>

        <div class="list" ng-repeat="r in itens track by $index" >

        <a class="item item-thumbnail-left" href="#/nhaac/restaurante_singles/">
              <img src="/img/logo_restaurante.jpg">

              <h2>{{r.fornecedores_fantasia}}  </h2>

              <h3>{{r.fornecedores_bairro}} </h3>  


                   <i><rating ng-model="contato.stars" max="rating.max"></rating></i>

              <p>Aqui a descrição do restaurante. </p>                  
              <button class="button button-block button-royal">
                  VER AS PROMOÇÕES
              </button>
            </a>

        </div>


        <ion-list class="list">
            <div class="item" ng-if="results.length == 0" >
                <p>Nenhum resultado encontrado...</p>
            </div>
        </ion-list>


    </ion-content>
</ion-view>

Remembering that I'm looking for the results of link

In my log, list everything. But the view does not list anything ...

    
asked by anonymous 06.07.2016 / 20:18

1 answer

0

I changed my controller to:

    $scope.itens = [];

$http.get('http://nhac.esy.es/lista_restaurantes.php')
.success(function(retorno){
    $scope.itens = retorno;
    console.log("leu");  
    console.log($scope.itens = retorno);
})
.error(function(erro){
   console.log(erro);
    console.log("não leu")
});

And the View, in the excerpt:

           <div class="list" ng-controller="restaurantesCtrl" ng-repeat="r in itens" >

        <a class="item item-thumbnail-left" href="#/nhaac/restaurante_singles/">
              <img src="/img/logo_restaurante.jpg">

              <h2>{{r.fornecedores_fantasia}}  </h2>

              <h3>{{r.fornecedores_bairro}} </h3>  


                   <i><rating ng-model="contato.stars" max="rating.max"></rating></i>

              <p>Aqui a descrição do restaurante. </p>                  
              <button class="button button-block button-royal">
                  VER AS PROMOÇÕES
              </button>
            </a>

        </div>

Now the message is:

ionic.bundle.js: 26771 Error: [ngRepeat: dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: r in items, Duplicate key: string: ", Duplicate value:" link     at ionic.bundle.js: 13415     at ngRepeatAction (ionic.bundle.js: 42146)     at $ watchCollectionAction (ionic.bundle.js: 30081)     at Scope $ digest (ionic.bundle.js: 30216)     at Scope $ apply (ionic.bundle.js: 30480)     at done (ionic.bundle.js: 24801)     at completeRequest (ionic.bundle.js: 24999)     at XMLHttpRequest.requestLoaded (ionic.bundle.js: 24940)

    
06.07.2016 / 20:57