首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >角步进器

角步进器
EN

Stack Overflow用户
提问于 2020-09-18 13:47:50
回答 1查看 186关注 0票数 1

我有一个步进器组件。在stepper-component.html中,我有四个组件作为mat-step,如下所示-

代码语言:javascript
复制
<div class="container-fluid">
  <mat-horizontal-stepper linear #stepper>
    <mat-step label="Step1">
      <component-1></component-1>
    </mat-step>
    <mat-step label="Step2">
      <component-2></component-2>
    </mat-step>
    <mat-step label="Step3">
      <component-3></component-3>
    </mat-step>
    <mat-step label="Step4">
      <component-4></component-4>
    </mat-step>
  </mat-horizontal-stepper>
</div>

我想通过点击不同组件中的一个按钮来访问component2,比如componentX,并在component2中执行一些函数。我该怎么做呢?

EN

回答 1

Stack Overflow用户

发布于 2020-09-18 13:52:21

您可以使用@Input() / @Output(),也可以直接在componentX中导入component2并调用该方法。例如,在您的componentX中:

代码语言:javascript
复制
constructor(private component2: Component2) {}

clickMethod() {
    this.component2.method();
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63949997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档