ngSemantic
ngSemantic copied to clipboard
sm-select multi default not working as expected
trafficstars
The following code will not put in the correct default of 12, 13 and 20 into the multi-select, I am not sure if this is a bug in Semantic UI or I am doing something wrong here. However if I change the item.list to a string array of the numbers the defaults will work correctly.
View
<sm-select class="fluid multiple" placeholder="Select Key" [(model)]="item.list">
<option *ngFor="let key of keys" [value]="key">{{key}}</option>
</sm-select>
Controller
// Everything before
export class TestComponent {
item: any;
keys: number[] = [11,12,13,14,15,16,17,18,19,20];
constructor() {
this.item = {
list: [ 12, 13, 20 ] // [ "12", "13", "20" ] -- Works correctly and will put in the defaults.
};
}
}
Hi, this works because the value attribute at options are strings. It's how HTML works.