299955/what-s-the-difference-between-ngif-ngfor-and-ngswitch
Directive
Purpose
Usage
Example
*ngIf
Conditionally adds/removes elements based on a boolean expression.
*ngIf="condition"
<p *ngIf="isVisible">Visible if true</p>
*ngFor
Iterates over a list and renders elements dynamically.
*ngFor="let item of items"
<li *ngFor="let user of users">{{ user.name }}</li>
*ngSwitch
Displays one element from multiple choices based on a matching value.
[ngSwitch]="expression" with *ngSwitchCase
<div [ngSwitch]="status"><p *ngSwitchCase="'Active'">Active</p><p *ngSwitchCase="'Inactive'">Inactive</p></div>
With the help of code, can you ...READ MORE
Aspect super() super(props) Purpose Calls the parent class constructor without passing ...READ MORE
Feature React Synthetic Events (SyntheticEvent) Native JavaScript Events (Event) Definition React’s ...READ MORE
In React, state and props are two ...READ MORE
Users do not have access to process.env ...READ MORE
We had the same issue and in ...READ MORE
Parameters React Angular Type React is a JavaScript library, and it ...READ MORE
Yes, I agree with Omkar AngularJs is ...READ MORE
In React Native, if you want to ...READ MORE
Child components can update the state of ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.