Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
fix: md-data-table injection on md-data-table-tr
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregcop1 committed Mar 28, 2016
1 parent b39c93b commit 89d63f4
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ng2-material/components/data_table/data_table_tr.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Input, Inject, forwardRef, ElementRef, AfterContentInit} from "angular2/core";
import {Component, Input, Inject, Optional, forwardRef, ElementRef, AfterContentInit} from "angular2/core";
import {MdDataTable} from "./data_table";
import {MdCheckbox} from "../checkbox/checkbox";
import "rxjs/add/operator/map";
Expand Down Expand Up @@ -32,7 +32,7 @@ export class MdDataTableTr implements AfterContentInit {
thDisplayed: boolean = false;
tdDisplayed: boolean = false;

constructor(@Inject(forwardRef(() => MdDataTable))
constructor(@Optional() @Inject(forwardRef(() => MdDataTable))
public table: MdDataTable, private _element: ElementRef) {
}

Expand Down Expand Up @@ -64,15 +64,17 @@ export class MdDataTableTr implements AfterContentInit {
}

ngAfterContentInit() {
let element = this._element.nativeElement;
this.isInHeader = element.parentElement.localName === 'thead';
this._initListeners();
if (null !== this.table && undefined !== this.table) {
let element = this._element.nativeElement;
this.isInHeader = element.parentElement.localName === 'thead';
this._initListeners();

this.thDisplayed = this.table.selectable && this.isInHeader;
this.tdDisplayed = this.table.selectable && !this.isInHeader;
this.thDisplayed = this.table.selectable && this.isInHeader;
this.tdDisplayed = this.table.selectable && !this.isInHeader;

if (this.isInHeader === false && this.selectableValue === undefined) {
this.selectableValue = Array.prototype.indexOf.call(element.parentNode.children, element).toString();
if (this.isInHeader === false && this.selectableValue === undefined) {
this.selectableValue = Array.prototype.indexOf.call(element.parentNode.children, element).toString();
}
}
}
}

0 comments on commit 89d63f4

Please sign in to comment.