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

Default country doesn't work #77

Open
morrowyn opened this issue Jul 24, 2021 · 3 comments
Open

Default country doesn't work #77

morrowyn opened this issue Jul 24, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@morrowyn
Copy link

morrowyn commented Jul 24, 2021

Hi,

I'm trying to set the default country as such. But the field stays empty:
component.ts

this.currentCountry = {alpha2Code:'DE', alpha3Code:null, callingCode:null, name:null, numericCode:null};

component.html

<mat-select-country appearance="outline"
                          label="Country"
                          formControlName="country"
                          [value]="currentCountry"
                          (onCountrySelected)="onCountrySelected($event)">
            </mat-select-country>

output:
image

The documentation specified I should: pass an empty Country object with alpha2 code populated to do alpha2 lookup)

Any idea what is wrong with my code?

Btw. Im using the following versions:
angular 12
@angular-material-extensions/select-country": "^5.0.1"
"svg-country-flags": "^1.2.10"

@AnthonyNahas AnthonyNahas self-assigned this Jul 24, 2021
@MoAsmar
Copy link

MoAsmar commented Aug 26, 2021

I faced the same issue, please update any fix soon @AnthonyNahas ?

@MoAsmar
Copy link

MoAsmar commented Aug 26, 2021

I suggest to make the value field require only 1 value from Country Model, which is for example alpha2Code or numericCode

@AnthonyNahas AnthonyNahas added the bug Something isn't working label Sep 3, 2021
@simionrobert
Copy link

For anyone who has a difficult time in setting the default country in reactive forms, setting only alpha2Code should work:

  this.identityCardFormGroup = this._formBuilder.group({
      taraEmiterii: [{ alpha2Code: 'RO' }, Validators.required],
      ...
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants