有没有办法将ViewEncapsulated自定义样式传递给组件?

时间:2018-06-26 22:59:26

标签: angular

我希望组件的用户能够传递模板的自定义样式,同时仍保留组件的ViewEncapsulation。以下示例不起作用,但类似于:

@Component({
  selector: 'my-component',
  template: `
    <div class="myClass">
      <div class="innerClass">
      </div>
    </div>
  `,
  styles: [customStyles]
})

export class CustomComponent {
  // input would be CSS as a string
  // ".myClass { text-align: center; }"
  @Input() customStyles: string;
}

是否有一种优雅的方法?

0 个答案:

没有答案
相关问题