【发布时间】:2020-06-25 07:17:01
【问题描述】:
你能帮我一个忙吗?
环境是angular9和primeng。
我有两页。
- 显示详细信息。
- 编辑/创建。
2.具有 p-dropdown 组件。这工作正常。
1.是问题。我可以显示值但不能显示标签。 我尝试如下。这不起作用。
{{types[info.type].label}}
列表是这样定义的。 x.component.ts
readonly types: SelectItem[] = [ { label: '---', value: null }, //index=0 { label: 'a', value: '0' }, //index=1 { label: 'b', value: '1' }, //index=2 { label: 'c', value: '2' }, //index=3 ];
如果 info.type = 1, 正确答案是'b',但它返回'a'。
types[info.type].label //
如何从值中搜索列表? 我的头像是这样的。
类型[值-> info.type].label
或
类型['' + info.type].label
这些当然是行不通的。 我的页面中有 350 个下拉菜单,所以如果可能的话,不要在 component.ts 中编写转换代码。
【问题讨论】:
-
您能否说明
info是如何定义的?
标签: angular typescript primeng