2
如何將元素的width屬性綁定到模型,然後從模型綁定到另一個dev?如何將div的寬度綁定到角度爲2.0的模型?
<div [width1]="style.width.px">
<div [style.width.px]="width2">
export class MyComponent
{
width1: number;
width2: number = width1 - 30;
}
如何將元素的width屬性綁定到模型,然後從模型綁定到另一個dev?如何將div的寬度綁定到角度爲2.0的模型?
<div [width1]="style.width.px">
<div [style.width.px]="width2">
export class MyComponent
{
width1: number;
width2: number = width1 - 30;
}
我會說:
<div #width1>
<div [style.width.px]="width2">
export class MyComponent
{
width1: number;
@ViewChild('width1') width1;
ngAfterViewInit(){
this.width2 = this.width1.nativeElement. width - 30;
}
}
寬度1在ngAfterViewInit() – Dynamic
它clientWidth工作未定義:) – Dynamic