What is the equivalent of ngShow and ngHide in Angular 2+?

I have a number of elements that I want to be visible under certain conditions. In AngularJS I would write <div ng-show=”myVar”>stuff</div> How can I do this in Angular 2+? 2Best Answer 21 The hidden property can be used for that [hidden]=”!myVar” See also https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden issues hidden has some issues though because it can conflict … Read more

How can I use “*ngIf else”?

I’m using Angular and I want to use *ngIf else (available since version 4) in this example: <div *ngIf=”isValid”> content here … </div> <div *ngIf=”!isValid”> other content here… </div> How can I achieve the same behavior with ngIf else? 19 s 19 Angular 4 and 5: Using else: <div *ngIf=”isValid;else other_content”> content here … </div> … Read more

Angular: conditional class with *ngClass

What is wrong with my Angular code? I am getting the following error: Cannot read property ‘remove’ of undefined at BrowserDomAdapter.removeClass <ol> <li *ngClass=”{active: step===’step1′}” (click)=”step=’step1′”>Step1</li> <li *ngClass=”{active: step===’step2′}” (click)=”step=’step2′”>Step2</li> <li *ngClass=”{active: step===’step3′}” (click)=”step=’step3′”>Step3</li> </ol> 22 s 22 Angular version 2+ provides several ways to add classes conditionally: type one [class.my_class] = “step === ‘step1′” … Read more