Skip to main content
added 166 characters in body
Source Link
Pranav C Balan
  • 115.4k
  • 25
  • 172
  • 195
function LoginController($scope) {
    $scope.post=post = [{
        {"name": "Shaw",
      "unit_price": 1586,
      "enable": true,
      "composition": [{
        "asset": "asset1"
      }, {
        "percentage": 15
      }]
    }, {
        {"name": "Allen",
      "unit_price": 1586,
      "enable": false,
      "composition": [{
        "asset": "asset2"
      }, {
        "percentage": 30
      }]}
    }

  ];
  $scope.data=[];data = [];
  var tempObj1=[];tempObj1 = [];
  for (i=0;i<$scope.post.length;i++)
i {
= 0; i < var$scope.post.length; tempObj1=i++) {
    var tempObj1 = {
   
      "name": $scope.post[i].name,              
        "unit_price": $scope.post[i].unit_price,
        "enable": $scope.post[i].enable,
        
      
     };
     tempObj1.composition=[];composition = [];
    tempObj2 = {
      tempObj2={"asset": $scope.post[i].composition[0].asset,
                   "percentage": $scope.post[i].composition[1].percentage
                  };
         tempObj1.composition.push(tempObj2);
    
     $scope.data.push(tempObj1);
  }
    console.log('data', $scope.data);
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<div ng-app ng-controller="LoginController">
      <table>
    <tr>
      <th>Name</th>
      <th>Unit_Price</th>
        <th>Enable</th>
      <th>Compostion
       <th>Compostion<table> <table>
          <th>asset</th>
           <th>percentage</th><th>
        </table><table>
      </th>
    </tr>
    <tr ng-repeat="i in data">
      <td>{{ i.name }}</td>
      <td>{{ i.unit_price }}</td>
      <td>{{ i.enable }}</td>
      <td>{{ i.composition[0].asset}}</td>
      <td>{{ i.composition[0].percentage }}</td>
    </tr>
  </table>
</div>
function LoginController($scope) {
    $scope.post= [
        {"name": "Shaw", "unit_price": 1586,"enable":true,"composition":[{"asset":"asset1"},{"percentage":15}]}, 
        {"name": "Allen", "unit_price": 1586,"enable":false,"composition":[{"asset":"asset2"},{"percentage":30}]}
   
 ];
 $scope.data=[];
 var tempObj1=[];
 for(i=0;i<$scope.post.length;i++)
 {
    var tempObj1={
       
        "name":$scope.post[i].name,              
        "unit_price":$scope.post[i].unit_price,
        "enable":$scope.post[i].enable,
        
      
     };
     tempObj1.composition=[];
         tempObj2={"asset":$scope.post[i].composition[0].asset,
                   "percentage":$scope.post[i].composition[1].percentage
                  };
         tempObj1.composition.push(tempObj2);
    
     $scope.data.push(tempObj1);
  }
    console.log('data',$scope.data);
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<div ng-app ng-controller="LoginController">
      <table>
   <tr>
      <th>Name</th>
      <th>Unit_Price</th>
        <th>Enable</th>
       <th>Compostion<table>
      <th>asset</th>
           <th>percentage</th></table></th>
   </tr>
   <tr ng-repeat="i in data">
      <td>{{ i.name }}</td>
      <td>{{ i.unit_price }}</td>
      <td>{{ i.enable }}</td>
      <td>{{ i.composition[0].asset}}</td>
      <td>{{ i.composition[0].percentage }}</td>
   </tr>
</table>
</div>
function LoginController($scope) {
  $scope.post = [{
      "name": "Shaw",
      "unit_price": 1586,
      "enable": true,
      "composition": [{
        "asset": "asset1"
      }, {
        "percentage": 15
      }]
    }, {
      "name": "Allen",
      "unit_price": 1586,
      "enable": false,
      "composition": [{
        "asset": "asset2"
      }, {
        "percentage": 30
      }]
    }

  ];
  $scope.data = [];
  var tempObj1 = [];
  for (i = 0; i < $scope.post.length; i++) {
    var tempObj1 = {
 
      "name": $scope.post[i].name,
      "unit_price": $scope.post[i].unit_price,
      "enable": $scope.post[i].enable,


    };
    tempObj1.composition = [];
    tempObj2 = {
      "asset": $scope.post[i].composition[0].asset,
      "percentage": $scope.post[i].composition[1].percentage
    };
    tempObj1.composition.push(tempObj2);

    $scope.data.push(tempObj1);
  }
  console.log('data', $scope.data);
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<div ng-app ng-controller="LoginController">
  <table>
    <tr>
      <th>Name</th>
      <th>Unit_Price</th>
      <th>Enable</th>
      <th>Compostion
        <table>
          <th>asset</th>
          <th>percentage</th>
        </table>
      </th>
    </tr>
    <tr ng-repeat="i in data">
      <td>{{ i.name }}</td>
      <td>{{ i.unit_price }}</td>
      <td>{{ i.enable }}</td>
      <td>{{ i.composition[0].asset}}</td>
      <td>{{ i.composition[0].percentage }}</td>
    </tr>
  </table>
</div>
Source Link
Muhsin Keloth
  • 8k
  • 7
  • 41
  • 61

function LoginController($scope) {
    $scope.post= [
        {"name": "Shaw", "unit_price": 1586,"enable":true,"composition":[{"asset":"asset1"},{"percentage":15}]}, 
        {"name": "Allen", "unit_price": 1586,"enable":false,"composition":[{"asset":"asset2"},{"percentage":30}]}
   
 ];
 $scope.data=[];
 var tempObj1=[];
 for(i=0;i<$scope.post.length;i++)
 {
    var tempObj1={
       
        "name":$scope.post[i].name,              
        "unit_price":$scope.post[i].unit_price,
        "enable":$scope.post[i].enable,
        
      
     };
     tempObj1.composition=[];
         tempObj2={"asset":$scope.post[i].composition[0].asset,
                   "percentage":$scope.post[i].composition[1].percentage
                  };
         tempObj1.composition.push(tempObj2);
    
     $scope.data.push(tempObj1);
  }
    console.log('data',$scope.data);
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<div ng-app ng-controller="LoginController">
      <table>
   <tr>
      <th>Name</th>
      <th>Unit_Price</th>
        <th>Enable</th>
       <th>Compostion<table>
      <th>asset</th>
           <th>percentage</th></table></th>
   </tr>
   <tr ng-repeat="i in data">
      <td>{{ i.name }}</td>
      <td>{{ i.unit_price }}</td>
      <td>{{ i.enable }}</td>
      <td>{{ i.composition[0].asset}}</td>
      <td>{{ i.composition[0].percentage }}</td>
   </tr>
</table>
</div>