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

fix(select): set value from queue when options change #2082

Merged
merged 4 commits into from
Nov 19, 2019
Merged

fix(select): set value from queue when options change #2082

merged 4 commits into from
Nov 19, 2019

Conversation

yggg
Copy link
Contributor

@yggg yggg commented Nov 18, 2019

Please read and mark the following check list before creating a pull request:

Short description of what this resolves:

Fixes #1921.
Also probably related to #1336.

@yggg yggg requested a review from nnixaa November 18, 2019 11:26
@codecov
Copy link

codecov bot commented Nov 18, 2019

Codecov Report

Merging #2082 into master will increase coverage by 0.02%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #2082      +/-   ##
==========================================
+ Coverage   84.58%   84.61%   +0.02%     
==========================================
  Files         235      235              
  Lines        8040     8046       +6     
  Branches      707      708       +1     
==========================================
+ Hits         6801     6808       +7     
  Misses       1020     1020              
+ Partials      219      218       -1
Impacted Files Coverage Δ
...mework/theme/components/select/select.component.ts 90.68% <100%> (+0.57%) ⬆️
...mework/theme/components/select/option.component.ts 98.18% <100%> (ø) ⬆️

@yggg yggg merged commit c934329 into akveo:master Nov 19, 2019
@yggg yggg deleted the fix/select-set-value-from-queue-on-options-change branch November 19, 2019 15:37
@kavishsoam
Copy link

Its actually very simple

we all have be doing it in all along our project
just use ngModel, and assign its fixed value where you are recieving its api

<nb-select size="medium" placeholder="Shows Filter" [(ngModel)]="selectedValue" (selectedChange)="multipleSelected($event)" >
<nb-option *ngFor="let show of showData" [value]="show"> {{show}}

  this.http.get(environment.api_url + this.apiType + '/state').subscribe(res => {
    console.log(res);
    this.showData = res['result'];
    this.selectedValue = res['result'][0]
  },err => {
    console.log(err);
  })

also keep in mind if you have your nbSelect within formgroup and there are formControlName you can either make ngModel standalone : true

or if that doesn't works set formControlname value by
this.formName.controls.fieldName.setValue(this.data[0].value);

shout out to 🎉
@rbrijesh

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

Successfully merging this pull request may close these issues.

nb-select not setting default value
3 participants