ngSemantic icon indicating copy to clipboard operation
ngSemantic copied to clipboard

sm-select multi default not working as expected

Open tspayne87 opened this issue 8 years ago • 1 comments
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.
        };
    }
}

tspayne87 avatar Dec 03 '16 17:12 tspayne87

Hi, this works because the value attribute at options are strings. It's how HTML works.

martinmanzo avatar Apr 24 '17 18:04 martinmanzo