将样式属性转换为 ng 样式

Convert style attribute to ng-style

我在 angularjs 应用程序中使用了以下样式,它工作正常。 这可以用 ng-style 代替吗,还是最好坚持我现在拥有的 style 属性?

style="border-bottom:solid {{command.name == 'Delete' ? '1px':'0px'}} lightgray;
                      padding-bottom:{{command.name == 'Delete' ? '10px':'0px'}};

我试过但没有用的 ng 风格的代码。

ng-style="{border-bottom:solid {{command.name == 'Delete' ? '1px':'0px'}} lightgray;
                   padding-bottom:{{command.name == 'Delete' ? '10px':'0px'}}; }"

那是因为它需要一个对象,不需要在里面做{{}}:

ng-style="{
    borderBottom: 'solid ' + (command.name == 'Delete' ? '1px':'0px') + ' lightgray',
    paddingBottom: (command.name == 'Delete' ? '10px':'0px')
}"