iterate maps with ng-for
See original GitHub issueI am trying to iterate over Map values with the built in ng-for
, but I can see that for some reason it is not working.
In the specs, you can iterate over a Map iterable with:
let map = new Map();
let values = map.values();
for (let item of values) {
console.log(item);
}
And none of the ES5 standard for (...)
/for (... in ...)
will work with that.
Does the built in ng-for
actually support iterating over maps?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:46 (14 by maintainers)
Top Results From Across the Web
How to iterate using ngFor loop Map containing key as string ...
This is because map.keys() returns an iterator. *ngFor can work with iterators, ...
Read more >How to iterate using ngFor loop Map containing key as string ...
JavaScript : How to iterate using ngFor loop Map containing key as string and values as map iteration [ Gift : Animated Search...
Read more >How to iterate over Map using ngFor and display them in order ...
[Solved]-How to iterate over Map using ngFor and display them in order on html in Angular 2+?-angular.js · If the keys are numbers...
Read more >How to iterate using ngFor loop Map containing ... - SyntaxFix
I am new to angular 5 and trying to iterate the map containing another map in typescript. How to iterate below this kind...
Read more >How to Iterate/loop map in TypeScript or Angular
Table of Contents · Solution 1 : Use built-in Map forEach function(). · Solution 2: Use ES6 [key,value] syntax · Solution 3: Using...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Maps have no orders in keys and hence they iteration is unpredictable. This was supported in ng1, but we think it was a mistake and will not be supported in NG2
The plan is to have a
mapToIterable
pipe<div *ng-for"var item of map | mapToIterable">
“Maps have no orders in keys and hence they iteration is unpredictable”.
So what? Set iteration is unpredicable in Java, does that mean it shouldn’t be iterated over?
No, this is just a mistake made in design that has become obvious in practice.
So much good in angular 2, just fix this thing please.