Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 多选下拉列表不工作角度2_Angular - Fatal编程技术网

Angular 多选下拉列表不工作角度2

Angular 多选下拉列表不工作角度2,angular,Angular,当前代码:我使用了bootstrap-select.min.js和bootstrap-select.min.css。出于下拉样式的目的,我使用了class=selectpicker。我已经给出了下面的代码。使用class=selectpicker下拉列表时不使用样式 <select class="form-control selectpicker" multiple="multiple" id="skill" [(ngModel)]="skills" name="skill"

当前代码:我使用了bootstrap-select.min.js和bootstrap-select.min.css。出于下拉样式的目的,我使用了class=selectpicker。我已经给出了下面的代码。使用class=selectpicker下拉列表时不使用样式

<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>
问题:问题是当我使用class=selectpicker下拉列表时,没有显示。当我检查控制台时,它显示:

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

请帮帮我。

我正在使用质数NG和角4,看看这个答案会对你有帮助

import {MultiSelectModule} from 'primeng/primeng';
双向值绑定是使用ngModel定义的,multiselect需要一组选项,其中每个选项都应遵循定义标签值属性的SelectItem接口

HTML


我鼓励你使用NgBootstrap,以避免使用任何其他JS包,避免任何不可预知的错误。我需要多下拉列表,在NgBootstrap中我搜索过,它不可用。请告诉我解决方案这是另一个答案的副本,但细节和解释要少得多。
<p-multiSelect [options]="cities" [(ngModel)]="selectedCities"></p-multiSelect>
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'});
    }

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