2016-01-29 23 views
0

HTML:NG-重複的顯示行等於沒有屬性的,甚至不顯示在HTML視圖數據

<div ng-repeat="addr in addrShipData"> 
    <input type="radio" name="resp1" ng-checked='true'/> 
     {{addr.addressLine1 +","+addr.addressLine2+", "+addr.city+ ","+addr.state+", "+addr.country+", "+addr.zipCode+","+addr.contactNum}} 
&nbsp;&nbsp;&nbsp;&nbsp; <a>Edit</a> 
</div> 

JS代碼:

var dataObj = []; 
    var shipDataObj = []; 
    //var addrShipData =[]; 
    function shipData(shipDataObj){ 

     for(i=0;i<shipDataObj.length;i++){ 
      dataObj.push(addressLine1 = shipDataObj[i].addressLine1); 
      dataObj.push(addressLine2 = shipDataObj[i].addressLine2); 
      dataObj.push(city = shipDataObj[i].city); 
      dataObj.push(state = shipDataObj[i].state); 
      dataObj.push(country = shipDataObj[i].country); 
      dataObj.push(zip = shipDataObj[i].zipCode); 
      dataObj.push(contactNum = shipDataObj[i].contactNumber); 
     } 
    } 
    appServices.getAddress(userData.customerId).then(function (data){ 

        if (data){ 
          console.log(data); 
          $scope.shipDataObj = data; 
          shipData(data); 
         console.log("dataObj properties: " + dataObj); 
         $scope.addrShipData = dataObj; 
         console.log($scope.addrShipData); 
        if ($scope.addrShipData){ 
           storeLocally.set('shipInfo :', $scope.addrShipData); 
          } 
          else{ 
           $scope.addressError = "No Address Found!";        
          }   
        console.log("address info:- " + $scope.addrShipData); 
        } 
       }), 
       function (data) { 
        if (data.status == 500) { 
         $scope.addressError = "Oops! No Address Found!"; 
        }; 
       }  

在js文件我調試我的代碼在HTML視圖中獲取$ scope.addrShipdata中的所有值我沒有任何價值。

我得到O/P這樣

在控制檯上: 1234沃勒AVE,suite1,弗裏蒙特,美國加利福尼亞州,246326,213-435-4365

在HTML視圖:這是顯示空白。編輯 0,編輯 0,編輯 0,編輯 0,編輯 0,編輯 O ,, ,,編輯

我也沒有收到任何錯誤。我不明白代碼中的問題在哪裏。

+0

http://jsfiddle.net/rn3ewy1e/如果你可以做一個小提琴,這將有助於我們解決您的問題,更好地 – trickpatty

回答

0

您還沒有創建正確的對象定義,您期望在ng-repeat tempalte。你也應該創建一個完整的對象,並將其推送到dataObj,這將基本上添加具有新屬性的對象。

代碼

for (i = 0; i < shipDataObj.length; i++) { 
    dataObj.push({ 
     addressLine1: shipDataObj[i].addressLine1, 
     addressLine2: shipDataObj[i].addressLine2, 
     city: shipDataObj[i].city, 
     state: shipDataObj[i].state, 
     country: shipDataObj[i].country, 
     zip: shipDataObj[i].zipCode, 
     contactNum: shipDataObj[i].contactNumber 
    }); 
} 
+0

@Pallavi它幫助? –