属性指令 - NgStyle指令

优质
小牛编辑
127浏览
2023-12-01
  1. selector: 'app-style-example',
  2. template: `
  3. <p style="padding: 1rem"
  4. [ngStyle]="alertStyles">
  5. `
  6. })
  7. export class StyleExampleComponent {
  8. borderStyle = '1px solid black';
  9. 'color': 'red',
  10. 'font-weight': 'bold',
  11. 'borderBottom': this.borderStyle
  12. };