angular - 在新的 Angular 中查看孩子
问题描述
我正在学习 Angular。如何更好地配置新的 Angular 8 视图子项?
@ViewChild('example', {read: ElementRef, static: false})
public example: ElementRef;
或者
@ViewChild('example', {read: ElementRef, static: true})
public example: ElementRef;
哪个更好?我什么时候应该使用static:true
vs static:false
?
解决方案
你可以去以下:
{ static: true }
ViewChild
当您要访问in时需要设置ngOnInit
。{ static: false }
只能在ngAfterViewInit
.
推荐阅读
- swift - 错误没有这样的模块'GoogleSignIn'Xcode 10.2
- jboss - 在 WildFly 的 keycloak 子系统中参数化安全部署名称
- javascript - 为什么使用“else if”语句会出现 NaN 错误?
- angular - 为什么选项要求花费很长时间来响应asp.net web api
- macos - Carbon API 的 64 位迁移
- java - Spring Boot - Thymeleaf 和 Json 模板
- sybase - 在sybase中触发插入另一个数据库
- configuration - 如何从 WSO2 获取有关 ERROR 的信息?
- python - 如何在模板中显示父母的孩子?
- node.js - 将 pm2 与 pkg 一起使用