【发布时间】:2021-10-07 23:40:51
【问题描述】:
我有一个 mat-checkbox,当我单击它时,我会显示一个 mat-dialog 组件,如果用户单击“确认”,我希望复选框被选中,如果他们按下取消,我希望它保持未选中状态,我该怎么做?
这里是复选框被点击时调用的方法:
onShowDialog(): void {
const dialogRef = this.dialog.open(ConfirmActionDialogComponent, {
width: '250px',
data: { title: 'Enable publish?'}
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
return true;
}
});
}
<mat-checkbox *ngIf="settingsChanged" (change)='onShowDialog($event)' formControlName="automaticallyPublish">Checkbox name</mat-checkbox>
【问题讨论】:
标签: html angular typescript checkbox angular-material