ngSemantic icon indicating copy to clipboard operation
ngSemantic copied to clipboard

sm-select active item doesn't work for me

Open PitPanda1 opened this issue 8 years ago • 3 comments

Hey there,

I have a problem to get sm-select's pre selection to work. In my Component I have the property "status" for the model i am using for sm-select and in my HTML-Template I have the following code:

<sm-select [options]="{direction: 'downward'}" (onChange)="onFilterChange('status', $event)" [(model)]="status" placeholder="Status...">
  <option *ngFor="let item of issueModel?.status" [value]="item.id"><i class="icon {{item.icon}}"></i>{{item.name}}</option>
</sm-select>

Now when I load the site with URL parameters http://.../site?status=1, the active item is not pre selected.

All is rendered fine and my selection is set properly in the status property in my component but its not pre-selected in the dropdown.

When I manually add an option field like so:

<sm-select [options]="{direction: 'downward'}" (onChange)="onFilterChange('status', $event)" [(model)]="status" placeholder="Status...">
  <option value="9">Nine</option>
  <option *ngFor="let item of issueModel?.status" [value]="item.id"><i class="icon {{item.icon}}"></i>{{item.id}}</option>
</sm-select>

I can visit the URL http://.../site?status=9 and the active item is set correct to "Nine" in the dropdown. I think it's a bug when using ngFor?

Anyone have a suggestion for my problem?

Greetings

PitPanda1 avatar Jan 10 '17 14:01 PitPanda1

<sm-select *ngIf="issueModel"> will solve your problem.

sguiheux avatar Feb 21 '17 15:02 sguiheux

Haha yea thx. I found it already myself. :)

PitPanda1 avatar Feb 21 '17 20:02 PitPanda1

Nice, this helped :) Is there any way to initiate the onChange event when the model gets updated?

snstarosciak avatar Mar 23 '17 00:03 snstarosciak