angular - 访问 DOM 中表示 Angular 组件的对象
问题描述
有没有办法通过某种引用访问 DOM 中表示 Angular 组件的对象并在其上调用方法?
解决方案
尝试
html
<component></component>
<div *ngIf="componentObj"> componentObj.Method() </div>
打字稿
@ViewChild(component)
public componentObj: ComponentType;
推荐阅读
- scala - 来自 Chisel(火箭芯片)的 sbt.TrapExitSecurityException 错误消息
- java - JPA - 同一类的列数错误。应该是 2
- python - 在 Elasticsearch 上出现连接错误
- javascript - 使用带有 nodejs 和 express 的 parse 和 back4app 上传和检索图像
- java - 从另一个列表中查找(自定义)列表中的对象
- c - uint8_t* - 指向 RGB 图像地址的指针
- java - Java:如何在不使用 Sort() 的情况下基于自定义对象 ArrayList 创建排序字符串 ArrayList
- python - 如何将抓取的数据发送到 postgresql 数据库
- bash - 如何在 s-nail 中设置 Content-Type?
- javascript - React Google Maps 不导入