通过单击显示子组件中任意行的详细信息,通过单击同一行关闭详细信息在Angular 2+;
我需要一些帮助来切换子组件中表行的值 只有在我单击某一行时,它才会显示。这种情况发生得很好。但是,如果我单击下一行,它将关闭详细信息,但它应该只切换值。如果我在同一行中单击两次,它将关闭详细信息通过单击显示子组件中任意行的详细信息,通过单击同一行关闭详细信息在Angular 2+;,angular,toggle,Angular,Toggle,我需要一些帮助来切换子组件中表行的值 只有在我单击某一行时,它才会显示。这种情况发生得很好。但是,如果我单击下一行,它将关闭详细信息,但它应该只切换值。如果我在同一行中单击两次,它将关闭详细信息 您必须像这样更改toggleDetails功能 toggleDetails(row) { console.log(row); if (this.rowData == row) { this.showDetails = !this.showDetails; } else
您必须像这样更改toggleDetails功能
toggleDetails(row) {
console.log(row);
if (this.rowData == row) {
this.showDetails = !this.showDetails;
} else {
this.showDetails = true;
}
this.rowData = row;
}
这会有用的 您必须像这样更改toggleDetails函数
toggleDetails(row) {
console.log(row);
if (this.rowData == row) {
this.showDetails = !this.showDetails;
} else {
this.showDetails = true;
}
this.rowData = row;
}
这会有用的 试试这个:
toggleDetails(row) {
console.log(row);
this.showDetails = row.position !== this.rowData.position || !this.showDetails;
this.rowData = row;
}
试试这个:
toggleDetails(row) {
console.log(row);
this.showDetails = row.position !== this.rowData.position || !this.showDetails;
this.rowData = row;
}
请看工作演示。我已经修改了
切换详细信息
方法。请查看工作演示。我已经修改了toggleDetails
方法。有效,但问题不大。类型{}上不存在this.rowData.position“”属性位置。this.rowData:any={}将修复此问题,但存在小问题。类型{}上不存在this.rowData.position“”属性位置。this.rowData:any={}将修复此问题