html - 在 Angular 中,是否可以根据您在第一个表格中选择的内容来填写第二个表格?

标签 html css angular typescript

我有两张 table 。第一个表是组列表。这些组中的每一个都有附加到他们的 session ,这就是第二个表要填写的内容。我想要发生的是,当用户点击第一个表中的一个组时,它旁边的第二个表会填充与该组关联的正确 session 。

我的表是这样设置的:

<div>
    <h1>Manage Workflows</h1>
</div>
<div class="table-responsive">
        <table class="table" id = "groups">
            <thead>
                <tr>
                <th scope="col">Group</th>
                </tr>
            </thead>
            <tbody>
                <tr>                  

                </tr>
            </tbody>
        </table>
        <table class="table" id = "sessions">
                <thead>
                    <tr>
                    <th scope="col">Session</th>
                    <th scope="col" id = "trigger">Next Trigger</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>

                    </tr>

                </tbody>
            </table>
    </div>

最佳答案

是的。您可以通过单击第一个表格的行来显示第二个表格中的详细信息。

给行添加点击事件,根据行id过滤数据。

public onRowClick(id: number): void {
    this.tableTwo= this.rows.filter(row => row.id === id);
  }

解决方案:https://stackblitz.com/edit/angular-table-add-record-dshxfy?file=src/app/app.component.html

关于html - 在 Angular 中,是否可以根据您在第一个表格中选择的内容来填写第二个表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58418932/

相关文章:

php - 在表格中显示为长文本,如果为真,则为表格的一行着色

javascript - 如何在拖放图像后将图像缩放到 div 上的完整大小?

css - Firefox 中的下拉边框问题

jquery - 内联列表元素,添加编号叠加

javascript - typescript | JavaScript | Angular 2 | @Output 与 @Input

javascript - 当请求实体的内容类型不是 application/x-www-form-urlencoded 时使用@FormParam]

javascript - 使用 Bootstrap 在 NavBar 底部导航?

javascript - 如何在 Angular 6 中导入 JS 文件?

Angular 7 - .json() 的 HttpClient 问题

javascript - 如何在需要客户端处理的 JavaScript 中保存大文件