有什么方法可以更新角度为4+的已创建键值对映射的值。
说我有:
testMap: Map<number, string> = new Map<number, string>();
ngOnInit() {
this.testMap.set(1, "A");
this.testMap.set(2, "B");
this.testMap.set(3, "C");
this.testMap.set(4, "D");
this.testMap.set(5, "E");
}
changeValue(id){
//id is the one of the keys of the map whose value needs to be altered
//let say (id=3)
this.testMap.put(id,"ChangedValue"); //PUT is from java
}
答案 0 :(得分:2)
您可以设置:
this.testMap.set(id, "ChangedValue")