多选择下拉不起作用角2
问题描述:
当前代码:我已使用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"
}-->
请帮助我。
答
我正在使用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'});
}
}
我鼓励你使用NgBootstrap,为了避免使用任何其他JS包,https://开头NG-引导。 github.io/#/components/dropdown/examples 以避免任何不可预知的错误。 –
我需要多个下拉列表,在我搜索的ngBootstrap中,它不可用。请告诉我解决方案 –
http://www.angulartutorial.net/2017/11/multi-checkbox-dropdown-component-using.html – Prashobh