如何在我的角度2應用程序中使用分組實現多個選擇下拉菜單?我需要像這個問題How can implement grouping in ng-select of Angular2?中鏈接的圖像一樣下拉。請幫我.....我被困在這從最近幾天如何在角度2應用程序中使用分組實現多個選擇下拉菜單?
我試圖像下面,但其角ngselect:
組件HTML:
<form [formGroup]="form" class="selector-form">
<div class="marTop20">
<ng-select [options]="options1"
[multiple]="multiple1"
placeholder="Select multiple"
formControlName="selectMultiple"
(opened)="onMultipleOpened()"
(closed)="onMultipleClosed()"
(selected)="onMultipleSelected($event)"
(deselected)="onMultipleDeselected($event)">
</ng-select>
</div>
</form>
組件代碼TS文件:
export class FilterClientSelectorComponent implements OnInit {
form: FormGroup;
multiple1: boolean = true;
options1: Array<any> = [];
selection: Array<string>;
@ViewChild('preMultiple') preMultiple;
logMultipleString: string = '';
constructor() {
let numOptions = 100;
let opts = new Array(numOptions);
for (let i = 0; i < numOptions; i++) {
opts[i] = {
value: i.toString(),
label: i.toString(),
groupname:'a'
};
}
this.options1 = opts.slice(0);
}
ngOnInit() {
this.form = new FormGroup({});
this.form.addControl('selectMultiple', new FormControl(''));
}
private scrollToBottom(elem) {
elem.scrollTop = elem.scrollHeight;
}
}
而且它給我多選dropdow n,而是不分組:
電流輸出:
需要的輸出:
@silentsod有格式的數據,現在檢查我的代碼哥們的響應 – Manjit