From e42c10e4a353b977353028451208f9f07bc8c16e Mon Sep 17 00:00:00 2001 From: Thomas Baum Date: Wed, 9 Sep 2020 15:58:34 +0200 Subject: [PATCH 1/2] textBoxRef is not initialized at the "OnInit" ... resulting in "TypeError: Cannot read property 'nativeElement' of undefined" error --- .../floating-text-entry/floating-text-entry.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/aia-lib/src/lib/components/aia-image-annotator/floating-text-entry/floating-text-entry.component.ts b/projects/aia-lib/src/lib/components/aia-image-annotator/floating-text-entry/floating-text-entry.component.ts index 419a653..7373cd5 100644 --- a/projects/aia-lib/src/lib/components/aia-image-annotator/floating-text-entry/floating-text-entry.component.ts +++ b/projects/aia-lib/src/lib/components/aia-image-annotator/floating-text-entry/floating-text-entry.component.ts @@ -5,7 +5,7 @@ import { Component, ViewChild, ElementRef, OnInit } from '@angular/core'; templateUrl: './floating-text-entry.component.html', styleUrls: ['./floating-text-entry.component.scss'] }) -export class FloatingTextEntryComponent implements OnInit { +export class FloatingTextEntryComponent implements AfterViewInit { public currentText = ''; private borderWidth = 2; @@ -14,7 +14,7 @@ export class FloatingTextEntryComponent implements OnInit { @ViewChild('p') pRef: ElementRef; @ViewChild('input') inputRef: ElementRef; - ngOnInit() { + ngAfterViewInit() { this.textBoxRef.nativeElement.style.borderWidth = this.borderWidth + 'px'; } From c36c7f87d1f556a0b7f826c1471418da73dc0c3d Mon Sep 17 00:00:00 2001 From: Thomas Baum Date: Wed, 9 Sep 2020 16:02:49 +0200 Subject: [PATCH 2/2] Update floating-text-entry.component.ts --- .../floating-text-entry/floating-text-entry.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aia-lib/src/lib/components/aia-image-annotator/floating-text-entry/floating-text-entry.component.ts b/projects/aia-lib/src/lib/components/aia-image-annotator/floating-text-entry/floating-text-entry.component.ts index 7373cd5..d63c6a4 100644 --- a/projects/aia-lib/src/lib/components/aia-image-annotator/floating-text-entry/floating-text-entry.component.ts +++ b/projects/aia-lib/src/lib/components/aia-image-annotator/floating-text-entry/floating-text-entry.component.ts @@ -1,4 +1,4 @@ -import { Component, ViewChild, ElementRef, OnInit } from '@angular/core'; +import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core'; @Component({ selector: 'aia-floating-text-entry',