【发布时间】:2018-08-30 04:25:10
【问题描述】:
我使用选择组件 2 次来选择时间,我还添加了图标作为后缀,以使操作为 add 和 cancel。如下图所示
这里是代码
HTML
<mat-form-field class="no-line time">
<mat-select [(value)]="selectmonmor">
<mat-option *ngFor="let mondaymorning of mondaymornings" [value]="mondaymorning.value">
{{mondaymorning.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="no-line time">
<mat-select [(value)]="selectmoneve">
<mat-option *ngFor="let mondayevening of mondayevenings" [value]="mondayevening.value">
{{mondayevening.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
<button mat-button matSuffix mat-icon-button >
<mat-icon (click)="toggleIcon()">{{icon}}</mat-icon>
</button>
TS
public icon = 'highlight_off';
public toggleIcon() {
if (this.icon === 'highlight_off') {
this.icon = 'add_circle_outline';
} else {
this.icon = 'highlight_off';
}
}
在这里单击图标,即<mat-icon (click)="toggleIcon()">{{icon}}</mat-icon> 取消图标(即highlight_off)它更改为添加图标(即add_circle_outline)现在我需要在点击取消图标时禁用 2 个下拉菜单(select 组件)然后图标将更改为 add,点击 add 选择组件要启用。在冲浪时我也得到了stackblitz 链接
但这里启用/禁用操作是通过 2 个单独的按钮使用 2 次单击功能执行的,但我需要它仅由一个图标执行。我该怎么做?
【问题讨论】:
-
这个问题如何获得 2 票和 5 次浏览。有什么可疑的
-
很抱歉我的同事投票了,我们正在处理同一个问题。@TamoDev
标签: angular angular-material angular6