I am trying to set the width and height of a component alongside its initial declaration in a parent component's html. Having the following component tag (in the parent's html):
<app-ipe-artboard [artboard]="artboard" [ngStyle]="setStyle()"></app-ipe-artboard>
Where setStyle()
is a method on the artboard component (itself):
@Component({
selector: 'app-ipe-artboard'
})
export class ArtboardComponent implements OnInit {
@Input() public artboard: Artboard;
ngOnInit() {
}
setStyle(): object {
return {
width: this.artboard.width + 'px',
height: this.artboard.height + 'px'
};
}
}
Is it possible to reach this method (not in the way I have put it now because it gives compile time error and undesired runtime behavior consecutively)? Or is the component not yet instantiated when it is rendered at this this place and does this need to be done somehow different?