Angular2 Renderer setElementStyle is not working

前端 未结 1 478
伪装坚强ぢ
伪装坚强ぢ 2021-01-17 02:35

This is my component metadata:

@Component({
   moduleId: module.id,
   selector: \'si-attribute-directive\',
   template: `
      
相关标签:
1条回答
  • 2021-01-17 03:28

    The problem is that you pass not native element. Try this:

    this._renderer.setElementStyle(this._elRef.nativeElement, 'background-color', this.customColor || this._defaultColor);
    
    0 讨论(0)
提交回复
热议问题