gpt4 book ai didi

angular - 如何在 Angular 4+ 中更新 map 现有键的值

转载 作者:行者123 更新时间:2023-12-05 08:40:51 24 4
gpt4 key购买 nike

<分区>

有什么方法可以更新 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
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com