Angular sm-select:加载时选择全部

时间:2017-09-12 06:49:20

标签: javascript jquery angular

我想在加载sm-select时选择所有选项。是否可以在* ngfor循环中选择选项?

我尝试在ngInit中填充multipleData数组,但它对我不起作用。

你能帮忙吗?

   // My file dashboard.component.html contains

<div class="ui form">
<label for="multipleControl">Categories</label>
<sm-select *ngIf="categories" [options]="{direction: 'downward'}" [(model)]="categories"  placeholder="Kategorie..." class="fluid search multiple" (onChange)="onMultiple('categories', $event)">
<option *ngFor="let category of categories [value]="category.id">{{category.name}}</option>
</sm-select>
</div>


//My file dashboard.component.ts contains

categories: Category[];


loadCategories() {  this.influencerService.getCategories().subscribe(categories => {
      this.categories = categories;
    },
      err => {
        console.log(err);
        return false;
      }
    );
  }

  onMultiple(data: Array<Category>): void {
    this.multipleData = data;
    console.log(this.multipleData);
}

0 个答案:

没有答案