1 import {Component, Input, OnInit, AfterViewInit, Host} from '@angular/core';
3 interface LinkTableLink {
10 selector: 'eg-link-table',
11 templateUrl: './link-table.component.html'
14 export class LinkTableComponent implements AfterViewInit {
15 @Input() columnCount: number;
16 links: LinkTableLink[];
28 // table-ize the links
29 const rowCount = Math.ceil(this.links.length / this.columnCount);
30 this.colWidth = Math.floor(12 / this.columnCount); // Bootstrap 12-grid
32 for (let col = 0; col < this.columnCount; col++) {
33 this.colList.push(col);
36 // Modifying values in AfterViewInit without other activity
37 // happening can result in the modified values not getting
38 // displayed until some action occurs. Modifing after
39 // via timeout works though.
41 for (let row = 0; row < rowCount; row++) {
42 this.rowBuckets[row] = [
44 this.links[row + Number(rowCount)],
45 this.links[row + Number(rowCount * 2)]
53 selector: 'eg-link-table-link',
54 template: '<ng-template></ng-template>'
57 export class LinkTableLinkComponent implements OnInit {
58 @Input() label: string;
60 @Input() routerLink: string;
62 constructor(@Host() private linkTable: LinkTableComponent) {}
65 this.linkTable.links.push({
68 routerLink: this.routerLink