2016-04-28 69 views
3

我們需要敏感的數據添加到數組,然後我們需要在html.We到dispaly試過這樣添加對象數組中的for循環angularjs

var RequestAs = []; 
for (var i = 0; i < RequestLength; i++) 
{ 
    $http({ 
     method: "GET", 
     url: "http://183.82.0.221:2244/api/PostPets/GetCustomerDetails?ID=" + results.rows.item(i).PosterId + "" 
    }).then(function mySucces(response) { 

     var RequestA = response.data; 
     $scope.RequestAs.push(RequestA); 


    }, function myError(response) { 
     alert(response); 
     //console.log('ERR'+response.message); 
    }); 
} 

我們試圖在HTML這樣

<div class="list" ng-hide="registered" ng-repeat="Reques in RequestAs"> 
    <div class="item tabs tabs-secondary tabs-icon-left"> 
     <a class="tab-item" href="#"> 
      <i class="icon ion-person"></i> 
      {{Reques.CustName}} 
     </a> 
    </div> 
    <div class="item item-text-wrap"> 
     {{Reques.Address}} 
    </div> 
</div> 

我們得到這樣 第一循環的數據

[ 
    { 
    "CustName": "Pavan", 
    "Address": "Hyd", 
    } 
] 

[ 
     { 
     "CustName": "Naveen", 
     "Address": "Eluru", 
     } 
    ] 

請指導我們。我的code.What worng在我們的最後一天stugglied。

+0

請告訴我預期的結果? –

+0

@AdityaSingh謝謝你的回覆。我們需要在Html中同時顯示兩個數組數據。請指導我們 –

+0

嘗試建議的答案,如果有任何問題,然後評論它 –

回答

0

你得到客戶詳細信息的數組,你必須從它那裏得到的對象,並且具有對象添加到索引0每個數組,試試這個

$scope.RequestAs.push(RequestA[0]); 
+0

感謝您的答覆。我們按照您的說法嘗試過,但沒有運氣。請向我們諮詢 –

+0

真的非常感謝。 –