Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sui select option how to show text e.g <option value="one"> NameOne</option> #291

Open
irfanmayo0786 opened this issue Sep 6, 2017 · 16 comments

Comments

@irfanmayo0786
Copy link

irfanmayo0786 commented Sep 6, 2017

<option value="one"> NameOne</option>
All thing working with sui select only thing i want to know how i can show. "Name One"
how to put NameOne in options?...

@irfanmayo0786
Copy link
Author

can any one tell me how to show NameOne instead of value in drop down selection?..

@trevordaniels
Copy link
Contributor

check out the docs page which shows how to use labelField or templates to achieve this

https://edcarroll.github.io/ng2-semantic-ui/#/modules/select

@irfanmayo0786
Copy link
Author

Nothing like that i saw the doc can you tell me which one it's is?

@trevordaniels
Copy link
Contributor

http://plnkr.co/edit/I3JQpmAdvrsZP5OX5N5K

@irfanmayo0786
Copy link
Author

irfanmayo0786 commented Sep 8, 2017

we can not give it directly mean static html? im my Case i have like that
<sui-select formControlName="questionType" (ngModelChange)="onChange($event,i,j)"> <sui-select-option value="radio" ></sui-select-option> <sui-select-option value="checkbox"></sui-select-option> <sui-select-option value="input"></sui-select-option> <sui-select-option value="date">Date</sui-select-option> </sui-select>

@trevordaniels
Copy link
Contributor

No, you cannot insert html directly here. You could use templates or a formatter function as outlined in the docs, or check out this pr to see what's coming soon #225

@irfanmayo0786
Copy link
Author

hello i'm using formControlName reactive form instead of the ngModel how can i bind it? still in my case when i bind it with formControlName it bind complete object of option like {name:'radio',value:'radio'} how can i solve it?

@irfanmayo0786
Copy link
Author

can you tell me how i can use formControlName instead of the [(ngModel)]

@irfanmayo0786
Copy link
Author

@trevordaniels i'm waiting your response on it.

@trevordaniels
Copy link
Contributor

trevordaniels commented Sep 8, 2017 via email

@irfanmayo0786
Copy link
Author

<sui-select class="selection" formControlName="questionType" [options]="options" labelField="name" [isSearchable]="searchable" [isDisabled]="disabled" #select> <sui-select-option *ngFor="let option of select.filteredOptions" [value]="option"> </sui-select-option> </sui-select>
this is my code i'm viewing that question type return {name:'ks',vlaue:'ksl'}

@trevordaniels
Copy link
Contributor

trevordaniels commented Sep 8, 2017 via email

@irfanmayo0786
Copy link
Author

where is the plunkr url i cannot see it bro. @trevordaniels

@irfanmayo0786
Copy link
Author

bro i checked it was for not a reactive forms. in reactive forms i got both values. key & name mean i got object in reactive forms.

@trevordaniels
Copy link
Contributor

trevordaniels commented Sep 12, 2017 via email

@dev-fullstacktechnology

Use like this if you have object and you want to return string value,

<sui-select class="selection form-control" [options]="selectMarketplaceOption" [(ngModel)]="listMarketPlaceDetail.marketplaceId" labelField="market" valueField="id" #marketSelect> <sui-select-option *ngFor="let option of marketSelect.filteredOptions" [value]="option"> </sui-select-option> </sui-select>

and my Array = [
{market: 'abc', id: 'd4rf42'},
{market: 'def', id: '7yh9y5'}
]

And It returns only id value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants