简体   繁体   English

@ViewChild 选项中的错误必须是 angular 9 中的 object 文字

[英]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.

相关问题 Angular:@Input()必须高于@ViewChild吗?为什么? - Angular: Must @Input() be above @ViewChild? And why? @ViewChild - Angular 13 上的初始化程序错误 - @ViewChild - initializer error on Angular 13 使用 ViewChild 访问 MatDrawer 在 Angular 8 中引发错误 - Access MatDrawer using ViewChild is throwing error in Angular 8 Angular @ViewChild() 错误:需要 2 个参数,但有 1 个 - Angular @ViewChild() error: Expected 2 arguments, but got 1 嵌套在ngIf中的组件的Angular2 @ViewChild错误 - Angular2 @ViewChild error for component nested in ngIf Angular 7 ViewChild抛出错误并且无法识别模态 - Angular 7 viewchild throwing error and not recognizing modal 错误:对象字面量只能以角度指定已知属性 - error: Object literal may only specify known properties in angular @viewChild 不触发模态弹出并抛出错误 triggerModal 不是函数 - Angular - @viewChild not triggering modal pop and throwing error triggerModal is not a function- Angular @ViewChild 无法在 angular-google-charts 中使用错误“图表未定义” - @ViewChild not working in angular-google-charts with error “chart is undefined” Angular 8 @ViewChild 模板变量错误 - 无法读取未定义的属性“nativeElement” - Angular 8 @ViewChild Template Variable Error - Cannot read property 'nativeElement' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM