Learn about *ngIf directive in Angular

angular
0
(0)

Learn about *ngIf directive in Angular

A structural directive that conditionally includes a template based on the value of an expression coerced to Boolean.
When the expression evaluates to true,
— Angular renders the template provided in a then clause,
When the expression evaluates to false or null
— Angular renders the template provided in an optional else clause. The default template for the else clause is blank.
loggedIn: boolean;
login() {
    this.loggedIn = true;
}

logout() {
  this.loggedIn = false;
}
<ul class="navbar-nav mr-auto" *ngIf="loggedIn">
  <li class="nav-item active">
     <a class="nav-link" href="#" >Matches
       <span class="sr-only">(current)</span>
     </a>
  </li>
  <li class="nav-item">
    <a class="nav-link">Lists</a>
  </li>
  <li class="nav-item">
    <a class="nav-link">Messages</a>
  </li>
</ul>

More on Angular ..

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Be the first to comment

Leave a Reply

Your email address will not be published.


*


13 + twelve =