Structural Directive in Angular2

There are three type of Structural directive in Angular 2
1) ngiF
2) ngFor
3) ngSwitch

import { Component } from '@angular/core';
  selector: 'my-app',
  template: `
    <h1>Structural Directive ngiF</h1>
  <p *ngIf="showHide"> ngIf structural directive content</p>
  <h1>Structural Directive ngFor</h1>
  	<li *ngFor="let fruit of fruits">{{fruit}}</li>
   <h1>Structural Directive ngSwitch</h1>
   <ul [ngSwitch]="birds">
  	<li *ngSwitchCase="'Peacock'">Peacock is avaliale</li>
  	<li *ngSwitchCase="'Parrot'">Parrot is avaliale</li>
	<li *ngSwitchDefault>No bird  found</li>
export class AppComponent { 
	public showHide = true;
	public fruits =['Orange','Lemon','Banana'];
	public birds = 'Parrot';


You can download the angulras 2 files from this link Angular 2files

42 thoughts on “Structural Directive in Angular2

Leave a Reply

Your email address will not be published. Required fields are marked *