user

Rakshit

6 Mar 2022

Angular: Change columns to rows, and rows to columns while running a *ngFor loop.

Angular

I want to make my columns as rows and rows as columns in the table view. How can I do that?

My data is given below;

data = [
{
	id: 1,
	name: 'Rakshit',
	age: 18
	salary: $15/hr
},
{
	id: 2,
	name: 'Ashish',
	age: 19
	salary: $18/hr
},
{
	id: 3,
	name: 'Pragnesh',
	age: 18
	salary: $20/hr
}
];

Using *ngFor I am able to make a table looks like below,

ID | Name | Age | Salary
1 | Rakshit | 18 | $15/hr
2 | Ashish | 19 | $18/hr
3 | Pragnesh| 18 | $20/hr

I want to change columns to row, my expected output should be,

ID | 1 | 2 | 3

Name | Rakshit | Ashish | Pragnesh

Age | 18 | 19 | 18
Salary | $15/hr | $18/hr | $20/hr

How do I loop it to get above results?

Ref: //blog.angular-university.io/angular-2-ngfor/

Comments

No Comments to show

© 2024 Copyrights reserved for web-brackets.com