-
Notifications
You must be signed in to change notification settings - Fork 248
Create a filter which takes map and returns a list of key value pairs. Useful for iterating over Maps #394
Comments
/sub |
@mhevery do you think that a |
We wrote simple straightforward implementation for our project: @NgFilter(name: 'mapToList')
class MapToListFilter {
call(Map map) {
return new Map.fromIterable(map.keys,
key: (key) => key,
value: (key) => new _KeyValue(key, map[key])).values;
}
}
class _KeyValue {
var key, value;
_KeyValue(this.key, this.value);
} But when we try to use it: <div ng-repeat="item in cmp.items | mapToList"
ng-click="cmp.select(item.key)">{{item.value}}</div> We get following error at runtime:
Have we really succeeded to screw up in these 10 LOC or maybe there is an issue in AngularDart? |
@antonmoiseev Your filter is taking a |
It does, there is a |
Does doing it this way make any difference?
|
Unfortunately no, the same thing. As I can see my filter is invoked multiple times, though I would expect it to be invoked only once. |
Would it not be more Dart-like to simply allow use of <div ng-repeat="item in aMap.keys">{{aMap[item]}}</div> though I understand that this would be breaking away from the AngularJS way. |
I like @chalin idea |
E.g. `map.keys`, `map.length`, etc. This is a proposed solution to dart-archive#394.
Finally found time yesterday to work on this. Hopefully, #605 will be enough to address the concerns raised by this issue. |
Btw, I wanted to mention that this issue is related to the following broader issue: #606. |
- E.g. `map.keys`, `map.length`, etc. This is a proposed solution to dart-archive#394. - Add support for the watching of map properties whose types are primitive (not collections). Work still needs to be done for map.keys and map.values.
- E.g. `map.keys`, `map.length`, etc. This is a proposed solution to dart-archive#394. - Add support for the watching of map properties whose types are primitive (not collections). Work still needs to be done for map.keys and map.values.
See: #397 (comment) |
…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.
MapFormatter can be used with repeat decorator to display a list of key value pairs Closes dart-archive#394
MapFormatter can be used with repeat decorator to display a list of key value pairs Closes dart-archive#394
MapFormatter can be used with repeat decorator to display a list of key value pairs Closes dart-archive#394
MapFormatter can be used with repeat decorator to display a list of key value pairs Closes dart-archive#394
this implies
The text was updated successfully, but these errors were encountered: