我有多行,如果我打开一行,那么我将无法切换它,我的意思是除非单击另一行来查看内部数据,否则它不会关闭。 如果我没有对表单进行任何更改,我必须能够切换行,如果我对该表单进行了更改,它必须向我显示当前显示的确认消息。
演示: DEMO
TS:
editEo(eo,index) {
if(this.eoInfoForm.dirty) {
this.confirmationDialogService.confirm('Please confirm..', 'Do you really want to save changes ?')
.then((confirmed) => {
let openedIndex = this.eoList.findIndex(obj => obj.OpenCloseStatus === true);
confirmed ? this.OpenCloseEvent(eo,openedIndex):this.OpenCloseEvent(eo,index);
if(confirmed){
console.log("works")
}
})
.catch(() => console.log('User dismissed the dialog (e.g., by using ESC, clicking the cross icon, or clicking outside the dialog)'));
}else {
// this.eoDetailsList = previous;
eo.isCollapse = !eo.isCollapse
this.OpenCloseEvent(eo,index);
}
}
HTML:
<a href="javascript:void(0);" (click)="editEo(eo,i)" class="accordion-toggle">+ </a>
最佳答案
只需替换行:
this.eoList[objIndex]['OpenCloseStatus'] = true;
与:
this.eoList[objIndex]['OpenCloseStatus'] = !this.eoList[objIndex]['OpenCloseStatus'];
关于javascript - 如何使用 Angular 8 切换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60736806/