I have an angular component with boolean input parameters. Based on whether they are true or false, I want to add a CSS class to the host. I know I can wrap my entire component in a div and use ngClass. But what if I don't want to add an extra div in my template? I just want the host to have those classes conditionally. Is that possible? Say this is my component:
export class AssetDetailsComponent {
@Input isSomethingTrue = true;
@Input isThisAlsoTrue = true;
constructor() {}
}
And this is what the template looks like:
<h1> Page heading </h2>
<p> Details </p>
Now based on the value of isSomethingTrue and isThisAlsoTrue, I want to apply 2 different CSS classes or styles to the host (to add some margin-top). How do I do that in the component?
h1orp. you can add conditional class in these tags too. in this way you don't need any extra div to wrap your component.