Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Old control flow is supported in latest angular version 18?

This is the latest control flow in angular 18.

@if(condition) {
   <button>If Condition</button>
} 
@else {
   <button>Else Condition</button>
}

And This is the old way.

<ng-container *ngIf="state1; else default">State 1 selected</ng-container>

<ng-template #default> No state is selected. </ng-template>

Does this old way is still valid in angular 18 or not?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Yes, you can use the old method, its a matter of preference.


The difference is that, we can use @if, @for directly without any imports.

But when doing *ngIf or *ngFor you need to import the CommonModule, or the directives directly NgIf, NgFor from '@angular/core'.


New Syntax Demo – no imports!

Old Syntax Demo – needs imports

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading