[英]ERROR in @ViewChild options must be an object literal in angular 9
I have upgraded my Angular project from Angular version 8 to Angular version 9. it was upgraded successfully but when I am running the project on localhost or when I am trying to build my project it is giving me the following error.我已将我的 Angular 项目从 Angular 版本 8 升级到 Angular 版本 9。它已成功升级,但是当我在本地主机上运行项目或尝试构建项目时出现以下错误。
ERROR in @ViewChild options must be an object literal
here is my @ViewChild syntax in some files that I am using.这是我正在使用的某些文件中的@ViewChild 语法。
@ViewChild('subjectbox',null) private elementRefsub: ElementRef;
I don't know what I am doing wrong here.我不知道我在这里做错了什么。
can anyone please help with this?有人可以帮忙吗?
Thanks in Advance!提前致谢!
If you do not need a metadata, you can write:如果您不需要元数据,您可以编写:
@ViewChild('subjectbox') private elementRefsub: ElementRef;
Metadata Properties: (examples for properties listed for your reference)元数据属性:(列出的属性示例供您参考)
selector - The directive type or the name used for querying. selector - 用于查询的指令类型或名称。
read - Used to read a different token from the queried elements. read - 用于从查询的元素中读取不同的标记。
@ViewChild('subjectbox', { read: ElementRef }) private elementRefsub: ElementRef;
static - True to resolve query results before change detection runs, false to resolve after change detection. static - 在更改检测运行之前解析查询结果为真,在更改检测后解析为假。 Defaults to false.
默认为假。
@ViewChild('subjectbox', { static: false }) private elementRefsub: ElementRef;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.