From d7c2b09697e682bef8f731482a91214bfb0d1949 Mon Sep 17 00:00:00 2001 From: Lotte Hofstede Date: Mon, 18 Dec 2017 13:57:01 +0100 Subject: [PATCH] print commit --- .../shared/truncatable/truncatable.component.html | 3 ++- src/app/shared/truncatable/truncatable.component.ts | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/shared/truncatable/truncatable.component.html b/src/app/shared/truncatable/truncatable.component.html index 1a778d1ea6..7b5c540a50 100644 --- a/src/app/shared/truncatable/truncatable.component.html +++ b/src/app/shared/truncatable/truncatable.component.html @@ -1 +1,2 @@ - \ No newline at end of file + +{{print(styles)}} \ No newline at end of file diff --git a/src/app/shared/truncatable/truncatable.component.ts b/src/app/shared/truncatable/truncatable.component.ts index cec9c287ac..ab4ca21b71 100644 --- a/src/app/shared/truncatable/truncatable.component.ts +++ b/src/app/shared/truncatable/truncatable.component.ts @@ -11,16 +11,22 @@ import { NativeWindowRef, NativeWindowService } from '../window.service'; selector: 'ds-truncatable', templateUrl: './truncatable.component.html' }) -export class TruncatableComponent implements AfterViewChecked { +export class TruncatableComponent implements OnInit { @Input() lines: Observable; @Input() innerHTML; @Input() height: Observable; + styles: any; public constructor(private elementRef:ElementRef, @Inject(NativeWindowService) private _window: NativeWindowRef) { } - ngAfterViewChecked(): void { + ngOnInit(): void { const lineHeight = this._window.nativeWindow.getComputedStyle(this.elementRef.nativeElement).lineHeight.replace('px', ''); + this.styles = this._window.nativeWindow.getComputedStyle(this.elementRef.nativeElement); this.height = this.lines.map((lines) => (lines * lineHeight)).startWith(0); - this.height.subscribe((h) => console.log('height: ', h)); + this.print(this.styles); + } + + print(styles) { + console.log(styles); } }