Vit*_*han 1 dictionary angular angular6
有什么方法可以更新 angular 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
}
Run Code Online (Sandbox Code Playgroud)
小智 9
你可以只设置:
this.testMap.set(id, "ChangedValue")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11605 次 |
| 最近记录: |