Does angular template supports if else
Yes. New Version of Angular framework support if elseLet’s take an example. In the following code snippet, I am using Angular
if else
directive to showing the user is Admin or not.Check the following example.$ads={1}
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<div *ngIf="isAdmin; else elseBlock">
Admin Area
</div>
<ng-template #elseBlock>
Normal User
</ng-template>
`,
styles: []
})
export class AppComponent {
isAdmin = true;
}