I am new to angular 5 and trying to iterate the map containing another map in typescript. How to iterate below this kind of map in angular below is code for component:
For Angular 6.1+ , you can use default pipe keyvalue ( Do review and upvote also ) :
-
{{recipient.key}} --> {{recipient.value}}
WORKING DEMO
For the previous version :
One simple solution to this is convert map to array : Array.from
Component Side :
map = new Map();
constructor(){
this.map.set("sss","sss");
this.map.set("aaa","sss");
this.map.set("sass","sss");
this.map.set("xxx","sss");
this.map.set("ss","sss");
this.map.forEach((value: string, key: string) => {
console.log(key, value);
});
}
getKeys(map){
return Array.from(map.keys());
}
Template Side :
-
{{recipient}}
WORKING DEMO