(Angular Material)用Autocomplete打造帶層級分類的DropDown
阿新 • • 發佈:2018-10-13
height member style con 編寫 bsp input ont ports
}
];
<mat-option style="font-size:12px; height: 30px;" *ngFor="let name of nameList.items"
[value]="name">
{{ name }}
</mat-option>
</mat-optgroup>
</mat-autocomplete>
完成。
效果如下圖
代碼實現
1、導入模塊
import {MatAutocompleteModule} from ‘@angular/material/autocomplete‘;
@NgModule({
imports:[
MatAutocompleteModule
]
})
2、編寫List內容
this.memberNameList = [ { onOffDist: ‘オン‘, items: [‘丁1‘, ‘徐2‘, ‘僑3‘] }, { onOffDist: ‘オフ‘, items: [‘趙4‘, ‘李5‘]
3、html實現
<input type="text" name="memberName" matInput formControlName="memberName" [matAutocomplete]="memberName" [value]="costData.teamMember"/> <mat-autocomplete style="font-size:12px; height: 30px;" #memberName="matAutocomplete"> <mat-optgroup *ngFor="let nameList of memberNameList" [label]="nameList.onOffDist">(Angular Material)用Autocomplete打造帶層級分類的DropDown