如何在 Angular 4 中为 Radio、复选框和文件设置 ng 样式



下面的代码适用于按钮,不使用ngstyle。

<input  type="{{y.cellNumber}}"  src="{{y.src}}"  value="{{y.name}}" style="height:20px;width:50px">

但是如果我使用 ngstyle 无法显示按钮,如何使用 ngstyle 来做到这一点

<input  type="{{y.cellNumber}}"  
        src="{{y.src}}"  value="{{y.name}}" 
        [style.height.px]="y.height*2"  
        [style.width.px]="y.width/2"   
        [style.background]="y.background" 
        [style.color]="y.color" >

在本例中使用 NgStyle:

<input 
[ngStyle]="{ 'background': y.background, 'color': y.color, 'height.px': y.height*2 , 'width.px': y.width/2 }">

最新更新