2016-06-14 77 views
0

我是angualar js和ionic的新手,在我的開發過程中,我遇到了一個我不知道的錯誤。它告訴我在腳本中有一個重複的名字。錯誤:[ngRepeat:dupes]重複在repeater

.config(function($stateProvider, $urlRouterProvider){ 
    $stateProvider 
    .state('tabs',{ 
     url: '/tab', 
     abstract:true, 
     templateUrl:'templates/tabs.html' 
    }) 

    .state('tabs.source',{ 
     url:'/source', 
     views:{ 
     'list-source':{ 
     templateUrl: 'templates/source.html', 
     controller: 'feedsctrl' 
     } 
     } 
    }) 

.state('tabs.keeps',{ 
     url:'/keeps', 
     views:{ 
     'list-keeps':{ 
     templateUrl: 'templates/keeps/keeps.html', 
     controller: 'keepsctrl' 
     } 
     } 
    }) 

.controller('keepsctrl',['$scope','$http',function($scope,$http){ 
$http.get('http://localhost/vivalooks/app_ion/templates/keeps/keeps.php').success(function(data){ 
     $scope.keeps=data ; 
    }); 
}]); 

keeps.php導致

[{"fname":"Benjamin","lname":"Blay","pic":"4r4545.jpg ","fav_id":"4","wardrobe":null,"fav_total":"1"}] 
下面

是keep.html腳本

<ion-header-bar class="bar-positive"> 
      <button class="icon ion-home button button-clear"></button> 
     <h1 class="title">vivalooks</h1> 
      <button class="icon ion-person button button-clear"></button> 
     </ion-header-bar> 

     <div class="bar bar-subheader item-input-inset bar-light"> 
     <label class="item-input-wrapper"> 
      <i class="icon ion-search placeholder-icon"></i> 
      <input type="search" placeholder="Search"> 

      </label> 

     </div> 
<ion-view> 


<ion-content class="has-subheader"> 

    <ion-list class="list-inset" ng-repeat="items in keeps"> 
    <ion-item class="item-text-wrap"> 
     <div class="thumbnails_v"> <img ng-src="http://localhost/vivalooks/resize_image/vivalooks.php?image={{item.pic}}&new_width=300&new_height=300""> 
      </div> 
     <p> 
     {{item.fname}} {{item.lname}} 
     </p> 

     </ion-item> 

    </ion-list> 

    </ion-content> 

</ion-view> 
+0

您是否正在循環(ng-repeat)保留模板中的$ scope.keeps?如果可能的話發佈ng-repeat html和保持數據的結構。基本上,這意味着您在保留數據中有重複的項目(根據角度)。 – Umair

+0

顯示代碼的html部分。 –

+0

@HamletHakobyan,我已經編輯了問題並顯示了部分html – neiza

回答

0

,我注意到的是你在重複使用錯誤的變量名的第一件事:

<ion-list class="list-inset" ng-repeat="items in keeps"> 

您打電話給VAL ue「項目」,並使用下面的「項目」。將其更改爲「項目」。

如果這不是問題,可能是數據有問題。你檢查了嗎?如果沒有,只需在HTTP請求中執行console.log(data)。