Iterate over object in Angular

前端 未结 17 1616
攒了一身酷
攒了一身酷 2020-11-22 12:19

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:

17条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 12:53

    If you have es6-shim or your tsconfig.json target es6, you could use ES6 Map to make it.

    var myDict = new Map();
    myDict.set('key1','value1');
    myDict.set('key2','value2');
    
    
    key:{{keyVal[0]}}, val:{{keyVal[1]}}

提交回复
热议问题