Skip to content

ngStyle #70

Open
Open
@deepthan

Description

@deepthan

ngStyle

添加变量到ngStyle中

pWidth = '100'
<p [ngStyle]="{'width.px': pWidth}"></p>

根据变量添加不同属性

showP = false
<p [ngStyle]="{'display': showP ? 'block': 'none'}"></p>

花式添加style

ts中直接在组件顶层dom添加style

@Component({
  selector       : 'p-sample',
  host       : {
    '[style.color]' : `'red'`
  }
})

html中添加style

<p [style.color]="'red'"></p>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions