I'm attempting to link the CSS class foo
to my parent component by utilizing @HostBinding
based on a condition I evaluate against a dynamic variable. However, I am struggling to get it to function as expected.
Here are the different approaches I have already tested:
export class MyComponent {
@Input()
public input: string;
@HostBinding('class.foo')
public isFoo: Boolean = this.checkIfCorrectInput();
constructor() {
}
private checkIfCorrectInput(){
return (this.input != 'not correct');
}
}
Is there a method I could use to make this work? Perhaps listening for changes in the input
value?