【发布时间】:2020-04-20 18:56:07
【问题描述】:
我有一个带有动态键和值的 Map,如下所示
public featureData = new Map<string, string>();
键值对如下(可能存在其他动态值)
[
{"name" : "Bangalore"},
{"type" : "city"},
{"lat" : "12.9716"},
{"lon" : "77.5946"}
]
为了在 HTML 中显示这些数据,我使用了以下代码
<div class="modal-body">
<div class="form-group">
<h4>
<ol>
<li *ngFor="let feature of this.featureData | keyvalue"> {{ feature.key }} : <input type="text" class="custom-field form-control form-control-sm form-control form-control-sm-sm" (change)="updateAnyHashMap(this.featureData, feature.key, $event.target.value)" autocomplete="off" value="{{ feature.value }}"> </li>
</ol>
</h4>
</div>
</div>
上面的代码给了我如下输出
但我需要使用 ngSwitch 禁用字段 lat 和 lon。这样我就可以得到如下输出
【问题讨论】:
-
到目前为止,您尝试过什么来解决这个问题?
-
这里不知道怎么用ngswitch。为了满足我的用例,根据我的理解,ngswitch 是唯一的解决方案
标签: typescript hashmap angular6 ng-switch angularjs-ng-switch