Gauravbhai Daxini
Gauravbhai Daxini

Reputation: 2190

Angular 4 Error: Cannot find control with unspecified name attribute

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> 

Upvotes: 4

Views: 30912

Answers (2)

sabeena kumarawadu
sabeena kumarawadu

Reputation: 165

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();

Upvotes: 2

user4676340
user4676340

Reputation:

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 ?

Upvotes: 23

Related Questions