How to use @HostBinding with @Input properties in Angular 2?

前端 未结 5 1626
青春惊慌失措
青春惊慌失措 2020-12-29 20:27

(Angular 2 RC4)

With @HostBinding we should be able to modify properties of the host, right? My question is, does this apply to @Input() properties as well and if so

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-29 20:49

    If your @Input is an object, you can do:

    @Input() settings: Settings;
    
    @HostBinding('class.active')
    public get isActive(): boolean {
      return this.settings.isActive;
    }
    

提交回复
热议问题