In order to use *ngIf without an extra element in Angular 2+, we can use either <ng-container> or <ng-template>
But in many cases, <ng-container> is recommended.
The best scenario regarding the usage of with *ngIf without an extra element is mentioned below.
If we inspect it then we can see there is no extra element added after <div> tag and before <p> tag.
- How to use *ngIf else in AngularJS ?
- How to truncate text in Angular2?
- How to pass string to a component using Angular2 ?
- How to display images in Angular2 ?
- How to trigger Form Validators in Angular2 ?
- AngularJS vs Angular2 | Features and Comparison
- Clone a stack without extra space
- SVG <use> Element
- How to use SVG with :before or :after pseudo element ?
- How to Remove extra right margin when using alert-dismissible ?
- How to add class to an element without addClass() method in jQuery ?
- How to search an element without using any loops in Node.js ?
- How to use SQLMAP to test a website for SQL Injection vulnerability
- How to use animation on favicon image ?
- Use of Shopify Apps
- How to use mailto in HTML ?
- How to use jQuery to Search and Replace HTML elements?
- What is the use of the @ symbol in PHP?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.