我想在加载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);
}