79129073

Date: 2024-10-26 17:17:44
Score: 0.5
Natty:
Report link

I had a similar problem. I wanted to be able to adjust the host style on certain components in a consistent way, but not all components (I am setting height and overflow). I used @HostBinding('style') and created a global constant. So each class I want to have this common style, I do this:

import { Component, HostBinding} from '@angular/core';
import { MAIN_CONTENT_HOST_STYLE} from '../../app.constants';

//Using HostBinding directly to set the Default style for main screen

@Component({
  selector: 'app-my-component',
  templateUrl: './my.component.html',
  styleUrls: ['./my.component.css']
})
export class MyComponent {
  @HostBinding('style') style = MAIN_CONTENT_HOST_STYLE;
}
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Stephen Patton