Skip to content

Commit ee4c08c

Browse files
committed
fix(angular): Set default country
1 parent 1efd69e commit ee4c08c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/angular/src/lib/components/country-selector/country-selector.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@ import { FormsModule } from "@angular/forms";
4646
export class CountrySelectorComponent {
4747
countries = countryData;
4848
value = model<CountryCode>();
49-
selected = computed(() => countryData.find((c) => c.code === this.value()));
49+
50+
selected = computed(() => {
51+
if (!this.value()) {
52+
return countryData[0];
53+
}
54+
55+
return countryData.find((c) => c.code === this.value()) as CountryData;
56+
});
5057

5158
handleCountryChange(code: string) {
5259
const country = this.countries.find((c) => c.code === code) as CountryData;

0 commit comments

Comments
 (0)