SQ-UI/ng-sq-ui

View on GitHub
projects/ng-datatable/src/lib/datatable-row/datatable-row.component.ts

Summary

Maintainability
A
0 mins
Test Coverage
F
50%
import {Component, Input, OnChanges, OnInit, SimpleChanges, ViewEncapsulation} from '@angular/core';

@Component({
  selector: '[sq-datatable-row]',
  templateUrl: './datatable-row.component.html',
  styleUrls: ['./datatable-row.component.scss'],
  encapsulation: ViewEncapsulation.None
})
export class DatatableRowComponent implements OnInit, OnChanges {
  @Input() rowItem: {[key: string]: any};
  @Input() width: string;

  columns = [];

  constructor() { }

  ngOnInit() {
  }

  ngOnChanges(changesObj: SimpleChanges) {
    if (changesObj.rowItem && changesObj.rowItem.currentValue) {
      if (!this.width) {
        this.columns = Object.keys(changesObj.rowItem.currentValue);
      }
    }
  }

}