How to show the element on a specific component angular

Viewed 31

I have a button on the nav menu that should show only on a specific component. I tried to put ngIf but it always return false. Any help?

1 Answers

you can add an input to your component.ts file like this:

@Input() showButton!: boolean;

then in your template:

<button *ngIf="showButton">...</button>

to use this component in your other templates:

<my-component [showButton]="true">show button</my-component>

or if you don't want to show it:

<my-component>Don't show button</my-component>

Related