美文网首页
多选多级下拉框案例

多选多级下拉框案例

作者: 晨曦Bai | 来源:发表于2020-09-09 09:13 被阅读0次

    忘了在哪儿找的啦

      viewValue: string[] = [];
      carProperties = [
        { value: 'Stereo' },
        {
          value: 'Radio',
          subProperties: [
            { value: 'Digital' },
            { value: 'FM' }
          ]
        }, { value: 'Child seats' },
        { value: 'Rear camera' }
      ];
    
      valueSelected(value: string): boolean {
        return this.viewValue.indexOf(value) !== -1;
      }
    
    <div>
    test
    
    <mat-form-field>
        <mat-select [(value)]="viewValue" multiple>
            <ng-container *ngFor="let property of carProperties">
                <mat-option [value]="property.value">
                    {{ property.value }}
                </mat-option>
                <div *ngIf="property.subProperties && valueSelected(property.value)">
                    <mat-radio-group>
                        <mat-radio-button *ngFor="let subProperty of property.subProperties" [value]="subProperty.value" style="display: block; padding: 12px 12px 12px 32px;">
                            {{ subProperty.value }}
                        </mat-radio-button>
                    </mat-radio-group>
                </div>
            </ng-container>
        </mat-select>
    </mat-form-field>
    

    </div>

    相关文章

      网友评论

          本文标题:多选多级下拉框案例

          本文链接:https://www.haomeiwen.com/subject/bgzxsktx.html