-
Notifications
You must be signed in to change notification settings - Fork 248
ng-repeat with a Map not working #359
Comments
This is intentional. We found that there were many issue with iterating over Maps, and so we decided not to support this feature. |
Could we at least have a better error message then? This is very misleading because it diverges from Angular JS. |
Is there some workaround? I tried:
I added a method on the controller that returns the keys of the map. Using this method worked Then I tried to repeat over a nested map which failed at Again adding a method to the controller solved this Obviously such an expression Should this work. Is this planned? |
Can you write a custom filter to do this?
Something which consumes a map and spits out a list? |
Filed #394 |
Thanks for you feedback! |
I almost cried after having spent my whole good Sunday on finding out why my ng-repeat didn't print anything until I stumbled upon this page. I converted Map to an array of Objects and it finally works. |
…and methods Closes dart-archive#359, dart-archive#394, dart-archive#397, dart-archive#757. Relates to dart-archive#772, dart-archive#773.
… to observe lists and maps Closes dart-archive#359, dart-archive#394, dart-archive#397, dart-archive#757. Relates to dart-archive#772, dart-archive#773.
… to observe lists and maps Closes dart-archive#359, dart-archive#394, dart-archive#397, dart-archive#757. Relates to dart-archive#772, dart-archive#773.
since the new change detection and some other work scheduled for 1.0 are going to fix ng-repeat over map.keys and map.values, doesn't it become possible to fix this bug and support (key, value) syntax in ng-repeat again? It would be great to have this just work for people migrating from angular.js, and it's just a handy syntax. Any chance of re-opening this issue? |
iterating over keys is problematic since key order is not guaranteed. We On Sun, Mar 23, 2014 at 4:00 PM, fringd [email protected] wrote:
|
Would it makes sense to allow iterating over keys for linked hash maps whose order is guaranteed ? On 24 mars 2014 15:25:54 CET, "Miško Hevery" [email protected] wrote:
|
order is guaranteed, but it is rather random. When you do ng-repeat you On Mon, Mar 24, 2014 at 8:43 AM, Victor Berchet [email protected]:
|
I think linked hash map promises the same order you put in right? many More to the point, now that i think if it... we have all these problems Filters sound like a good solution too... What would it look? for item in aMap.keys | stabilizeOrder or something else?
|
Guys, this is really confusing. I just spent 2 hours trying to figure out why this doesn't work:
HTML:
Result:
I can speak only for myself. For me the selective behavior for Maps is counter-intuivive. I think if the template engine supports iteration over ANY Iterable then Map.keys should be supported. Thoughts? |
This issue has already been discussed ans should be fixed when #1040 is in. |
Got it! Thanks for the great explanation! |
Did this ever get fixed? It doesn't seem to work with |
does it support iterate map in ng-repeat now? for my opinion, just iterate with original order is ok. just like ng-options. |
When trying to use ng-repeat over a map:
<span ng-repeat="(key, value) in {'a': 1, 'b': 2, 'c': 3}">
{{key}}: {{value}}
</span>
which is described in the Angular JS documentation:
http://docs.angularjs.org/api/ng.directive:ngRepeat#!
I get the following error:
type '_LinkedHashMap' is not a subtype of type 'List' of 'value'.
The text was updated successfully, but these errors were encountered: