【发布时间】:2019-06-28 21:33:36
【问题描述】:
concerts: [
{
key: "field_concerts_time",
lbl: "Date"
}, {
key: ["field_concert_fromtime", "field_concert_totime"],
lbl: "Time",
concat: "to"
}, {
key: "field_concerts_agereq",
lbl: "Age Requirements"
}, {
key: "field_concerts_dresscode",
lbl: "Dress Code"
}, {
key: "field_concerts_prices",
lbl: "Prices"
}
]
descriptions: {
"field_concerts_time": [
{
"value": "2019-09-16T00:00:00",
}
],
"field_concert_totime": [
{
"value": "1:00AM"
}
],
"field_concert_fromtime": [
{
"value": "7:30PM"
}
]
}
我有音乐会数组和描述对象,我想从音乐会中获取“键”并为该字段获取值
<p *ngFor="let otherdetail of otherdetailsarray">
<span *ngIf="descriptions[otherdetail.key][0].value !== null">
{{otherdetail.lbl}} :</span>
<span *ngIf="descriptions[otherdetail.key][0].value !== null &&
descriptions[otherdetail.key][0].value !== undefined">
{{descriptions[otherdetail.key][0].value }}</span>
</p>
我得到了第一个索引键“field_concerts_time”的值,并使用上述标签从描述中获取了值。我希望这段代码支持"key: ["field_concert_fromtime", "field_concert_totime"]"
【问题讨论】:
标签: arrays typescript angular6 javascript-objects