priyanka.sarkar priyanka.sarkar - 1 month ago 8
AngularJS Question

Column value merging in AngularJS

How to perfom column value merging in AngularJS?

Answer

Make your JSON

var jsonData = [
                  {
                    "bucket": ">120",
                    "productCodes": ["SBML", "SBHL"]                  
                  },
                  {
                    "bucket": "1-30",
                    "productCodes": ["SBHL", "SBML", "SBML+"]
                  },
                  {
                    "bucket": "X",
                    "productCodes": ["SBNL++"]
                  }
                ];

and you view

<body ng-app="myApp">       
    <div ng-controller="MyCtrl" align="center">  
        <table border="1">
            <tr>

                  <th>Bucket</th>   
                  <th>PRODUCT_CODE</th>              
                  <th>Allocated #</th>                   
            </tr>
            <tr ng-repeat="p in products">

                  <td><span>{{p.bucket}}</span></td>                                     
                  <td><span ng-repeat="c in p.productCodes">{{c}}</span></td>
                  <td><span>{{p.productCodes.length}}</span></td>                     
            </tr>               
        </table>
    </div>      
</body>
</html>