如何在Angular 4中为Radio,checkbox和File设置ng-style

时间:2018-04-19 13:48:36

标签: html angular types

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



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

但如果我使用ngstyle无法显示按钮,那么如何使用ngstyle进行操作

&#13;
&#13;
<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" >
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

在此示例中使用NgStyle:

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