1

This works:

  @HostBinding('style.width') get w() {
    return this.width ? this.width : '';
  }
  @HostBinding('style.height') get h() {
    return this.height ? this.height : '';
  }

Is there a way to do this with a single @HostBinding?

Ole
  • 41,793
  • 59
  • 191
  • 359
  • 1
    This has already been addressed here https://www.google.com/url?sa=t&source=web&rct=j&url=https://stackoverflow.com/questions/46150788/inject-style-declarations-using-hostbinding-in-angular&ved=2ahUKEwiA97Ckkf7kAhVc7HMBHVnWAWMQjjgwAHoECAIQAQ&usg=AOvVaw3GeQNFQD6KaUPtncGqoCt3 – Abhishek Bag Oct 02 '19 at 17:50
  • Ah - So we need to use the Sanitizer - Good tip - Thanks! – Ole Oct 02 '19 at 18:14

0 Answers0