【发布时间】:2021-04-27 11:43:05
【问题描述】:
我有一个类似的 api 响应
res.attribute
0: {relate_id: 15, pid: 9, attr_slug: "size", items: "s,m,l", id: 1, …}
1: {relate_id: 16, pid: 9, attr_slug: "color", items: "yellow", id: 2, …}
length: 2
我需要两组用于大小和颜色的单选按钮。我通过它实现了这一点
<section class="example-section" *ngFor="let attr of Attr" >
<mat-radio-button *ngFor="let checkbox of attr.items.split(',')" class="example-margin">{{checkbox}}</mat-radio-button>
</section>
但是,每个单选按钮的名称都一样(只能从所有 4 个(s、m、l、yellow)中选择一个)
我期待的是两组不同的单选按钮,例如大小和颜色
【问题讨论】:
标签: html angular typescript