typescript Angular 2 Map<String, List<String>> 可以创建吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39223902/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 03:48:15  来源:igfitidea点击:

Angular 2 Map<String, List<String>> is possible to create?

angulartypescript

提问by Mateusz Sobczak

is possible to create in angular 2 Map< String, List< String >>?

是否可以在 angular 2 Map< String, List< String >> 中创建?

回答by Andzej Maciusovic

Map is ES6 feature and have nothing to do with Angular 2. You can create it using

Map 是 ES6 特性,与 Angular 2 无关。您可以使用创建它

var map = new Map<string, string[]>();
map.set('key', ['a', 'b', 'c']);
map.get('key');

You also need to set "module": "es6" in your tsconfig.json or use es6-shims definitions.

您还需要在 tsconfig.json 中设置 "module": "es6" 或使用 es6-shims 定义。