MAT-List-Item(Mat-Nav-list)内部的角材料MAT-Checkbox
我想实现一份交易列表。在悬停项目时,复选框将变得可见且可选,但是如果用户不想选择特定项目,只需单击事务本身,在右窗格上,相关信息将在单击(带有路由器参数)上显示。
我的问题是,如何使用复选框分开的点击和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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您使用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