I have a problem with @input(), two out of three input have an undefined value when I want to use it but can be display using interpolation in the template file.
.ts :
export class NoteCanvasPageComponent {
@Input() note: any;
@Input() canvasWidth: any;
@Input() canvasHeight: any;
@ViewChild("TextArea") textArea: any;
constructor() {
}
ngAfterViewInit(){
console.log(this.note.posY + " " + this.canvasHeight);
console.log(this.note.posX + " " + this.canvasWidth);
this.textArea.nativeElement.style.top = this.note.posY * this.canvasHeight;
this.textArea.nativeElement.style.left = this.note.posX * this.canvasWidth;
}
}
console.log() print this :
0.623 undefined
0.578 undefined
template file :
<textarea #TextArea class="note-canvas-page">
{{note.text}}
{{canvasHeight}}
{{canvasWidth}}
</textarea>
Give :
This is a note
512
360
Why only two out of three input have undefined value in the component file ?
I use the component like this :
<div *ngFor="let note of arrayNotes">
<note-canvas-page [canvasHeight]=canvasHeight [canvasWidth]=canvasWidth [note]=note *ngIf="note.display"></note-canvas-page>
</div>
Thank you for your help
{{canvasHeight}}in note-canvas-pagecanvasHeight,canvasWidth,note