Skip to content

Commit 80014cd

Browse files
committed
fix(package): prevent invalid value error when type or country are null #100
1 parent 93e1d68 commit 80014cd

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/module/component/mat-google-maps-autocomplete.component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,20 @@ export class MatGoogleMapsAutocompleteComponent implements OnInit {
8585
ngOnInit(): void {
8686
this.addressValidator.subscribe(this.onNewPlaceResult);
8787

88-
const options = {
88+
const options: any = {
8989
// types: ['address'],
90-
componentRestrictions: {country: this.country},
90+
// componentRestrictions: {country: this.country},
9191
placeIdOnly: this.placeIdOnly,
9292
strictBounds: this.strictBounds,
93-
types: this.types,
93+
// types: this.types,
9494
type: this.type
9595
};
9696

97+
// tslint:disable-next-line:no-unused-expression
98+
this.country ? options.push({componentRestrictions: {country: this.country}}) : null;
99+
// tslint:disable-next-line:no-unused-expression
100+
this.country ? options.push({types: this.types}) : null;
101+
97102
this.autoCompleteOptions = Object.assign(this.autoCompleteOptions, options);
98103
this.initGoogleMapsAutocomplete();
99104
}

src/module/directives/mat-google-maps-autocomplete.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class MatGoogleMapsAutocompleteDirective implements OnInit {
6565
componentRestrictions: {country: this.country},
6666
placeIdOnly: this.placeIdOnly,
6767
strictBounds: this.strictBounds,
68-
types: this.types,
68+
// types: this.types,
6969
type: this.type
7070
};
7171

0 commit comments

Comments
 (0)