Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过单击显示子组件中任意行的详细信息,通过单击同一行关闭详细信息在Angular 2+;_Angular_Toggle - Fatal编程技术网

通过单击显示子组件中任意行的详细信息,通过单击同一行关闭详细信息在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={}将修复此问题