MAT-List-Item(Mat-Nav-list)内部的角材料MAT-Checkbox

发布于 2025-02-07 10:22:11 字数 664 浏览 0 评论 0原文

我想实现一份交易列表。在悬停项目时,复选框将变得可见且可选,但是如果用户不想选择特定项目,只需单击事务本身,在右窗格上,相关信息将在单击(带有路由器参数)上显示。

我的问题是,如何使用复选框分开的点击和MAT-List-Item本身的点击列表进行物质导航列表?

edit1: 我能够用锚标签列出一个列表,但是不幸的是,如果我单击锚固标签的复选框,则无法检查复选框。我可以以某种方式改变这种行为吗?

<mat-nav-list>
<a mat-list-item *ngFor="let transItem of transItems" [routerLink]="transItem.id" routerLinkActive="active" [disableRipple]="true">
    <div mat-list-icon>
        <mat-checkbox [checked]="selection.isSelected(transItem)" (change)="selection.toggle(transItem)"></mat-checkbox>
    </div>
    <div matLine>
         {{ transItem.id }}
    </div>
</a>

I would like to achieve to have a list of transactions. On hovering an item the checkbox would become visible and selectable, but if the user doesn't want to select the specific item just click on the transaction itself, on the right pane the relevant information would be shown on click(with router params).

My question would be how can I make a material navigation list with the clicks separated by the checkbox, and the mat-list-item itself?

EDIT1:
I was able to make a list with anchor tags, but unfortunately, if I click on the checkbox inside the anchor tag the checkbox doesn't get checked. Can I somehow change this behavior?

<mat-nav-list>
<a mat-list-item *ngFor="let transItem of transItems" [routerLink]="transItem.id" routerLinkActive="active" [disableRipple]="true">
    <div mat-list-icon>
        <mat-checkbox [checked]="selection.isSelected(transItem)" (change)="selection.toggle(transItem)"></mat-checkbox>
    </div>
    <div matLine>
         {{ transItem.id }}
    </div>
</a>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

信愁 2025-02-14 10:22:11

我建议您使用Mat-Tree。
从您的描述中至少,听起来像是满足您的要求的方式。
https://material.io oio/components/components/tree/tree/tree/tree/exmples

=“ https://stackblitz.com/run?file=src/app/tree-checklist-example.ts” rel =“ nofollow noreferrer”> https://stackblitz.com/run?file=src/app/tree -CheckList-example.ts

I would suggest you to use the mat-tree.
Atleast from your description it sounds like meeting your requirements some how.
https://material.angular.io/components/tree/examples

https://stackblitz.com/run?file=src/app/tree-checklist-example.ts

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文