angular-material-extensions / select-country

Angular Material component that allow users to select a country or nationality with an autocomplete feature
https://angular-material-extensions.github.io/select-country/
MIT License
126 stars 40 forks source link

Support for formControl + mat-error + clearable #118

Closed Rogermax closed 1 year ago

Rogermax commented 1 year ago

Support to pass a formControl:

Solves #75 #87

    <mat-select-country
      appearance="outline"
      label="Country"
      [language]="languageSelected"
      [autocomplete]="'no'"
      [showCallingCode]="showCallingCode == 'true'"
      [formControl]="countryMandatoryFormControl"
      [cleareable]="true"
      [error]="'Mandatory field'"
      (onCountrySelected)="onCountrySelected($event)"
    >
    </mat-select-country>
  countryMandatoryFormControl = new FormControl(null, [Validators.required]);

  ngOnInit(): void {
    this.countryMandatoryFormControl.valueChanges.subscribe((country) => {
      console.log(
        "this.countryMandatoryFormControl.get('country').valueChanges",
        country
      );
    });
  }