我有一个动态创建某个表单的应用程序,使用angular2 ans bootstrap 3.当我尝试使用引导网格动态调整组件样式时,我遇到了一些麻烦。
我写了这个:
[ngStyle]="['col-xs-12','col-sm-'+field.span,'col-md-'+field.span,'col-lg-'+field.span]"
'field'被正确限制,我没有错误,'span'属性是1到12之间的数字,探索div似乎没有样式。
答案 0 :(得分:1)
ngStyle
具有不同的目的或使用方式不同。看来你想要的是ngClass
[ngClass]="['col-xs-12','col-sm-'+field.span,'col-md-'+field.span,'col-lg-'+field.span]"
ngStyle
用例类似于
[ngStyle]="{color: someColorProperty}"