Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

display component based on a conditional

Tags:

angular

I have this field in app.component.ts

front: boolean = true;

And I am displaying this component template in app.component.html

<app-navbar></app-navbar>

That works, but I want to display that component (or not) based on the value of front, so i tried something like this which does not work:

<*ngIf="front" app-navbar></app-navbar>

How to achieve this?

like image 417
Vojislav Kovacevic Avatar asked Dec 20 '25 03:12

Vojislav Kovacevic


2 Answers

Put ngIf after app-navbar(component name)

<app-navbar *ngIf="front"></app-navbar>
like image 154
Pankaj Parkar Avatar answered Dec 22 '25 21:12

Pankaj Parkar


<app-navbar *ngIf="front"></app-navbar>

You have to open the tag (with app-nav) and then use the *ngIf

like image 21
Christian Benseler Avatar answered Dec 22 '25 20:12

Christian Benseler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!