java - 如何在 Jhipster 的前端使用 HashMap?
问题描述
我正在开发一个 Jhipster 应用程序,其中我有一个带有Map<String, String>
, 在后端的实体一切正常。但我不知道如何在实体详细信息视图中显示地图,因为 jhipster 不会向我生成它,我必须手动完成。
我从角度开始,我不知道如何在 html 中声明地图entity.model.ts
或如何在 html 中进行迭代。
实体.java
....Other attributes....
@ElementCollection(fetch=FetchType.EAGER)
@MapKeyColumn(name="key")
@Column(name="value")
@CollectionTable(name="map", joinColumns=@JoinColumn(name="entity_id"))
private Map<String, String> map= new HashMap<>();
....getters and setters....
实体模型.ts
export class entity implements BaseEntity {
constructor(
public id?: number,
public name?: string,
) {
}
}
实体-view.component.html
<div class="modal-body">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><span>Key</span></th>
<th><span>Value</span></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let map of entity.map">
<td><span>{{map.key}}</span></td>
<td><span>{{map.value}}</span></td>
</tr>
</tbody>
</table>
</div>
</div>
解决方案
推荐阅读
- sql - case statement in index creation
- java - 线程“主”java.lang 中的异常
- amazon-web-services - 在 AWS ECS FARGATE 容器上验证端到端加密
- php - file_put_contents 未能将图像存储到目录中
- javascript - 带有列表和键中的 id 的离子 ngmodel
- macos - DynaLoader.pm 找不到 libssl
- android - FirebaseUI 找不到资源文件的字体属性
- python - 测试值“本地”时,Django QuerySet 查找失败
- javascript - 如何检测被覆盖元素的鼠标悬停事件
- reactjs - graphql:使用动态过滤条件进行查询