import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
isValid = true;
numbers = [1,2,3,4,5,6,7,8,9,10];
}
<h1>ngIf example in angular</h1>
<p *ngIf="isValid">
Data is valid.
</p>
<p *ngIf="!isValid">
Data is not valid.
</p>
<div *ngFor="let id of numbers">
<div *ngIf="id%2 == 0">
<div>{{id}}-Even Number</div>
</div>
<div *ngIf="id%2 == 1">
<div>{{id}}-Odd Number</div>
</div>
</div>
Output:
No comments:
Post a Comment