我想仅为一个特定选项创建一个两级单选按钮。在这里,我编写了一个逻辑,将在“Spring”选项下显示额外的两个单选按钮。但是当它被选择时,它会呈现所有选项。对齐也没有按预期发生。
超文本标记语言
<mat-radio-group class = "radio-group"[(ngModel)]="favoriteSeason">
<mat-radio-button class="example-radio-button" *ngFor="let season of seasons" [value]="season">
{{season}}
<mat-radio-group class = "radio-group" *ngIf="favoriteSeason ==='Spring'">
<mat-radio-button class="example-radio-button" *ngFor="let season of climate" [value]="season">
{{season}}
</mat-radio-button>
</mat-radio-group>
</mat-radio-button>
</mat-radio-group>
打字稿
export class RadioNgModelExample {
favoriteSeason: string;
seasons: string[] = ['Winter', 'Spring', 'Summer', 'Autumn'];
climate:string[]=['rainy','hot'];
}
我想像这样创作。
饮歌长啸
aluckdog
相关分类