Is it possible to controll 3 divs using *ngIf in Angular 2?
Can I do something like
<div *ngIf="planState=plan1">show plan 1</div>
<div *ngIf="planState=plan2">show plan 2</div>
<div *ngIf="planState=plan3">show plan 3</div>
Thanks!
I have update your plunker code as below and it works:
@Component({
selector: 'my-app',
template: `
<button (click)="OnButtonClick(1)">select - 1</button>
<button (click)="OnButtonClick(2)">select - 2</button>
<button (click)="OnButtonClick(3)">select - 3</button>
<h5>You selected : {{value}}</h5>
<hr>
<div>
<div *ngIf="value==1">1. Template - <b>{{value}}</b> </div>
<div *ngIf="value==2">2. Template - <b>{{value}}</b> </div>
<div *ngIf="value==3">3. Template - <b>{{value}}</b> </div>
<div *ngIf="value==0">Default Template</div>
</div>
`,
})
export class AppComponent {
value:number=0;
OnButtonClick(value)
{
this.value=value
}
}