【发布时间】:2020-06-29 21:59:27
【问题描述】:
当用户将鼠标悬停在表格的第一列上时,会出现一个工具提示,底部有一个按钮。
点击按钮后,角垫对话框打开,其中第一列数据位于垫对话框的左侧。
我需要完成两件事
1) 在 mat-dialog 的左侧,mat-list-option 应默认选中,具体取决于用户悬停在哪一行并单击其工具提示按钮。
2) mat-dialog 的右侧需要填充与左侧选择的 mat-list-option 相关的“conditionals”、“offset”、“alert”属性数据。
例如:在表格中,用户已将鼠标悬停在 1 分钟数据上(在警报列下)并在工具提示打开后单击按钮,在 mat-dialog 中应选择 1 分钟数据行并打开右侧应加载其各自的“条件”、“偏移”、“警报”数据,因此应根据所选的 mat-list-option 加载其各自的“条件”数据。
我已经强制一次只能选择一个 mat-list-option
alert-dialog.component.html
<div [ngStyle]="{'width':'50%','border':'1px solid yellow','margin-right':'15px','height':'100%'}">
<h3>LEFT</h3>
<div class="alert-select">
<mat-selection-list #preDefAlertList>
<mat-list-option *ngFor="let preDef of data.data" [value]="preDef">
{{preDef.Alert}}
</mat-list-option>
</mat-selection-list>
</div>
</div>
<div [ngStyle]="{'width':'100%','border':'1px solid red'}">
<h3>Edit JSON</h3>
<div class="makeEditable" contenteditable="true">
{{preDef.conditionals | json}}
</div>
</div>
tooltip-overview-example.component.ts 有表格,一旦用户点击工具提示中的按钮,数据就会被传递到 alert-dialog.component.ts。
Stackblitz 链接 https://stackblitz.com/edit/angular-mat-tooltip-rzstlk?file=app%2Ftooltip-overview-example.ts
【问题讨论】:
-
基本上我必须在 mat-dialog 的左侧显示预先选择的 mat-list-option,在 mat-dialog 的右侧显示相同的 json 数据(在工具提示中显示)但是当用户选择一些不同的 mat-list-option 时,它们各自的“条件”、“偏移”、“警报” json 数据
标签: javascript angular angular7 angular-material2