ngx-google-places-autocomplete icon indicating copy to clipboard operation
ngx-google-places-autocomplete copied to clipboard

Options Error - All fields required

Open franzbascope opened this issue 3 years ago • 2 comments

When I try to input options it is showing me this error:

Type '{ componentRestrictions: { country: string; }; }' is missing the following properties from type 'Options': bounds, types, fields, strictBounds, origin

17 [options]="{ ~~~~~~~

The error is because in the Options Interface all properties are required. However, I think these should be optional. For example, I want to restrict the country , but I do not want to set bounds, and this is not possible right now, please help. Thank you

Versions "@angular/core": "^12.0.0", "ngx-google-places-autocomplete": "^2.0.5",

franzbascope avatar Oct 11 '21 20:10 franzbascope

you can set to null but i agree that these should be optional.

google docs have these as optional https://developers.google.com/maps/documentation/javascript/reference/places-widget#AutocompleteOptions

finitekaren avatar Oct 13 '21 17:10 finitekaren

HTML <input type="text" ngx-google-places-autocomplete [options]="myOptions">

TS import { Options } from 'ngx-google-places-autocomplete/objects/options/options';

myOptions: any; // class variable

constructor() { this.myOptions = new Options({ componentRestrictions: { country: 'code' } }); // can use any of the restriction(s) }

mayurgudi avatar Dec 01 '21 13:12 mayurgudi