Reputation: 1663
How to bind the width property of an element to the model then from model to another dev?
<div [width1]="style.width.px">
<div [style.width.px]="width2">
export class MyComponent
{
width1: number;
width2: number = width1 - 30;
}
Upvotes: 3
Views: 2572
Reputation: 28590
I'd say :
<div #width1>
<div [style.width.px]="width2">
export class MyComponent
{
width1: number;
@ViewChild('width1') width1;
ngAfterViewInit(){
this.width2 = this.width1.nativeElement. width - 30;
}
}
Upvotes: 2