import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { Router } from '@angular/router'; @Component({ selector: 'app-table', templateUrl: './table.component.html', styleUrls: ['./table.component.less'] }) export class TableComponent implements OnInit { @Input() tableData; @Input() optFn; @Output() fromChild = new EventEmitter(); toolList; childTableTdCount; constructor(private router: Router) { } ngOnInit() { if (this.tableData.td) { this.childTableTdCount = this.tableData.td.length; } this.childTableTdCount += this.tableData.operate ? 1 : 0; this.childTableTdCount += this.tableData.childTh ? 1 : 0; } isToggle(obj) { obj.isShow = !obj.isShow; } optClick(obj, optName) { this.fromChild.emit({ optInfo: { targetObj: obj, optName: optName } }); } }