The “ If ” evaluates expression and then renders the “ else ” or “ then ” template in its place when expression is “truthy” or “falsy” respectively. Stayed Informed – Angular 4 vs. Angular 2 Stayed Informed – Angular 2 if else examples Then : - This template is the inline template of “ If ” unless bound to a different value. Else : - This template is blank unless it is bound. Selectors : - 1. If 2. If then 3. If else The multiple examples for Angular 4 if else and then as given bellows, Syntax:- <element * ngIf= "[condition expression]; else [else template]" > </element> Syntax:- <div * ngIf= "users | async; else loadingGrid; let user" > <p> {{user.Id}} </p> <p> {{user.name}} </p> <p> {{user.Age}} </p> </div> <ng -template # loadingGrid > loading... < /ng-templ...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers