1

I am using angular.js for font-end and node.js for server side.

Now, I am having some list of values in array randomly.

Html code :

<html ng-app='app' ng-controller='mainController'>

<head>
</head>

<body>
  <div class="container">

    <div class="jumbotron">
      <table><tr ng-repeat="report in reports">
        <td style="padding-left:10px;">{{report.salary_head_value11}}</td>
        <td style="padding-left:10px;">{{report.salary_head_value12}}</td>
        <td style="padding-left:10px;">{{report.salary_head_value13}}</td>
        <td style="padding-left:10px;">{{report.salary_head_value14}}</td>
        <td style="padding-left:10px;">{{report.salary_head_value15}}</td>

        </tr>
      </table>
    </div>
  </div>
  <pre>{{ cleanData | json}}</pre>
</body>

</html>

Controller code :

angular.module('app', [])

.controller('mainController', ['$scope', '$filter', function($scope, $filter) {
$scope.reports = [{
"salary_head_value11":100,
"salary_head_value12":300,
"salary_head_value13":200,
"salary_head_value14":800,
"salary_head_value15":500
},{
"salary_head_value11":200,
"salary_head_value12":400,
"salary_head_value13":900,
"salary_head_value14":800,
"salary_head_value15":600
}];

}]);

Output :

enter image description here

Expected code :

i want to print the same output without using {{report.salary_head_value11}} ......{{report.salary_head_value15}} in ng-repeat

1 Answer 1

2

If you dont need the string name salary_head_value, you can turn the array of objects into a 2d array:

$scope.reports = [
    [ 100, 300, 200, 800, 500 ],
    [ 200, 400, 900, 800, 600 ]
];

Then in HTML:

<table>
    <tr ng-repeat="report in reports">
        <td style="padding-left:10px;" ng-repeat="val in report">{{val}}</td>
    </tr>
</table>

Note: untested, this is the concept, please modify it if there are syntax errors

Sign up to request clarification or add additional context in comments.

5 Comments

,i have one more doubt in the above query, How to skip first 2 value in ng repeat in <td> values.
you want to skip first 2? ng-show="$index > 1" maybe.
great it's also working fine ,one more thing, how skip last index value.
the output not printed as sequence, how to print as sequence.
Can you elaborate on that? What do you mean by sequence

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.