I am trying to do some things in Angular 2 Alpha 28, and am having an issue with dictionaries and NgFor.
I have an interface in TypeScript looking like this:
Use the built-in keyvalue-pipe like this:
Key: {{item.key}} and Value: {{item.value}}
or like this:
Key: {{item.key}} and Value: {{item.value}}
where mySortingFunction is in your .ts file, for example:
mySortingFunction = (a, b) => {
return a.key > b.key ? -1 : 1;
}
Stackblitz: https://stackblitz.com/edit/angular-iterate-key-value
You won't need to register this in any module, since Angular pipes work out of the box in any template.
It also works for Javascript-Maps.