4

I have used google place API following this tutorial but I am getting this error below:

Cannot find control with unspecified name attribute

more detail about error in below screenshot

I have tried also this all hint stackoverflow link

Code

<div class="form-group"> 
<input #search
    type="text"
    placeholder="search for location"
    autocorrect="off"
    autocapitalize="off"
    spellcheck="off"
    class="form-control"
    [formControl]="searchControl"
    name="searchControl"> 
</div> 
Stphane
  • 3,368
  • 5
  • 32
  • 47
Gauravbhai Daxini
  • 2,032
  • 2
  • 22
  • 28

2 Answers2

23

You should post some code, we're not mediums !

But seeing your error, I would say you're using reactive forms, and you forgot to create your reactive forms.

This means on your input, you have [formControl]="" or formControlName="" attribute, which can't find the corresponding variable.

Could you post the related code of that please ?

2

Your HTML code looks fine for me, I think this has occurred because you have not initialized searchControl variable in the corresponding JavaScript/TypeScript file.

Add this line into your class in JavaScript/TypeScript file

searchControl = new FormControl();