Skip to main content

angular - How to use if then condition

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

export class AppComponent {
  showParagraph:boolean = true;
}
app.component.html

<h2>Angular If Then Condition</h2>

<div *ngIf="showParagraph then lorem_ipsum"></div>

<ng-template #lorem_ipsum>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    Donec tincidunt est quam, nec hendrerit nisl laoreet laoreet.
</ng-template>
More Angular tutorials