2017-07-18 101 views
0

當前代碼:我已使用bootstrap-select.min.js and bootstrap-select.min.css。而對於下拉式樣的目的,我使用了class =「selectpicker」。我已經給出了下面的代碼。無需使用class =「selectpicker」下拉菜單,而無需使用樣式。多選擇下拉不起作用角2

<select class="form-control selectpicker" multiple="multiple" id="skill" [(ngModel)]="skills" name="skill" #skill="ngModel"> <option *ngFor="let skill of skillType.skills" [value]="skill.skill_id" >{{skill.skill_descr}}</option> </select> 

問題:當我使用類= 「selectpicker」 下拉沒有顯示問題是。當我檢查控制檯它顯示:

<!--bindings={ 
    "ng-reflect-ng-for-of": "[object Object],[object Object" 
}--> 

請幫助我。

+0

我鼓勵你使用NgBootstrap,爲了避免使用任何其他JS包,https://開頭NG-引導。 github.io/#/components/dropdown/examples 以避免任何不可預知的錯誤。 –

+0

我需要多個下拉列表,在我搜索的ngBootstrap中,它不可用。請告訴我解決方案 –

+0

http://www.angulartutorial.net/2017/11/multi-checkbox-dropdown-component-using.html – Prashobh

回答

0

我正在使用Angular 4的Prime NG,看到這個答案會幫助你。

import {MultiSelectModule} from 'primeng/primeng'; 

雙向值結合使用ngModel定義和多選要求的其中每個選項應遵循的SelectItem接口,定義標籤值屬性選項集合。

HTML

<p-multiSelect [options]="cities" [(ngModel)]="selectedCities"></p-multiSelect> 

ANGULAR打字稿

import {SelectItem} from 'primeng/primeng'; 

export class MyModel { 

    cities: SelectItem[]; 

    selectedCities: string[]; 

    constructor() { 
     this.cities = []; 
     this.cities.push({label:'New York', value:'New York'}); 
     this.cities.push({label:'Rome', value:'Rome'}); 
     this.cities.push({label:'London', value:'London'}); 
     this.cities.push({label:'Istanbul', value:'Istanbul'}); 
     this.cities.push({label:'Paris', value:'Paris'}); 
    } 

}