DO YOU NEED A CONTENT WRITER FOR YOUR BUSINESS?

Your One-Stop Solution for All Content Needs! Click here for more!
AngularJS

AngularJS Tables

Share

In AngularJS Tables we can show repeatable data. Using ng-repeat directive we can draw table easily. See the below example how to use ng-repeat in table.

Table data is normally repeatable by default and ng-repeat directive can be used perfectly to create table easily.

Example of AngularJS Tables:

<table>
   <tr>
      <th>Name</th>
      <th>Age</th>
   </tr>
   <tr ng-repeat="x in user">
      <td>{{ x.name }}</td>
      <td>{{ x.age }}</td>
   </tr>
</table>

Read Also: HTML DOM – AngularJS

OutPut:

NameAge
John Doe25
Jane Doe21
Robert Stuart35

To sort the table, add an orderBy filter:

<tr ng-repeat="x in user | orderBy : 'name'">
 <td>{{ x.name }}</td>
 <td>{{ x.age }}</td>
</tr>

In order to display the table index, use <td> with $index:

<tr ng-repeat="x in user">
<td>{{ $index + 1 }}</td>
<td>{{ x.name }}</td> 
<td>{{ x.age }}</td> 
</tr>

For example:

No.NameAge
1John Doe25
2Jane Doe21
3Robert Stuart35
Jacob Frazier

Based on United States, Jacob Frazier is a skilled JavaScript developer with over 8 years of experience. He is passionate about change and trying new things, both professionally and personally. He loves startups and is extremely proactive.

View Comments

  • Makes sense. I just wanted to throw it out there in case there was some part I didn't understand. Thanks.

Recent Posts

Writing Tools That Help Content Marketers Produce Cleaner Work

Content marketing has a hidden tax. It's not the writing itself, it's everything that happens…

4 days ago

How Data Analytics Is Actually Driving Smarter Marketing Decisions

Most marketing teams aren't failing because they lack data. They're failing because they can't act…

2 weeks ago

The Ultimate SPF Tester Guide: Boost Email Deliverability In Minutes

Email marketing continues to be one of the most effective ways for businesses to communicate,…

2 weeks ago

Sales Ops: A role that helps sales teams work as efficiently as possible

Xerox first introduced it around the mid-1970s. The need came up because the management activities…

3 weeks ago

Forex Investment Tips for Beginners

Investing in the forex market may look to be a dangerous game. With some worthwhile…

3 weeks ago

How Did The Restaurant Industry change In Post Pandemic Era?

The coronavirus outbreak has drastically changed the way we live our lives. Yes, that's absolutely…

1 month ago