Javascript Angular 4 错误:找不到具有未指定名称属性的控件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47809696/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 03:57:03  来源:igfitidea点击:

Angular 4 Error: Cannot find control with unspecified name attribute

javascriptangulargoogleplacesautocomplete

提问by gauravbhai daxini

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

我在本教程之后使用了 google place API,但出现以下错误:

Cannot find control with unspecified name attribute

找不到具有未指定名称属性的控件

more detail about error in below screenshot

有关以下屏幕截图中错误的更多详细信息

I have tried also this all hint stackoverflow link

我也试过这个所有提示stackoverflow 链接

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> 

回答by

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.

这意味着在您的输入中,您有[formControl]=""formControlName=""属性,但找不到相应的变量。

Could you post the related code of that please ?

你能发布相关的代码吗?