

Angular – ngFor iterate object or Maps
source link: https://www.tuicool.com/articles/hit/zmY7viI
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Sometimes you got an object or a maps and you want to iterate it with an ngFor but until today it was impossible to do without implementing your custom pipe or use some nice library.
Today angular release a new version 6.1 and looking on the release notes I found a nice feature that has been added:
common: introduce KeyValuePipe (#24319) (2b49bf7)
Using this new pipe is quite easy and straightforward. Our template will look something like that:
As you can see the only new thing we added is the keyvalue pipe at the end of our ngFor.
The component instead will be something like that:
If you need this feature go on and update your angular dependencies to 6.1.
If you enjoyed this post leave a comment and follow me on twitter @DZurico
Recommend
-
24
-
10
In this post, you will be introduced to looping through lists in Angular using the ngFor directive and keywords like index, first and last. Before You Start To be able to follow through i...
-
9
ng-for loop The ng-for loop is a structural directive. We will see how to change the structure of the dom. Point is to repeat given HTML ones for each value in an array[]. Context is each time passing the array value f...
-
2
How to iterate easily over object properties in JavaScript ...
-
14
How to get the JSON iterate object and the JSON array using JavaScript. For each advertisements I have the following JSON object:
-
5
Reading Time: 3 minutes Introduction
-
4
How to Use Built-In Angular Directive: ngIf, ngFor, ngClass, and More By Sharlene Von Drehnen Published 7 hours ago ...
-
4
How To Iterate Over Object Keys With JavaScript Custom objects cannot be iterated over using the for...of loop. In addition, you can't use iterator methods like map() a...
-
9
How to Use the ngFor Angular Directive By Sharlene Von Drehnen Published 5 hours ago Discover all you n...
-
3
How to access the index in an Angular ngFor loopNick Scialli • August 20, 2022 • 🚀 1 minute readIn Angular, we can loop through an array using the ngFor struc...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK