trackBy in Angular
⭐ What Is trackBy in Angular? When Angular uses *ngFor to loop over a list, it re-renders the entire list whenever the array changes—even if only one item changed. This can cause: ❌ Unnecessary...
⭐ What Is trackBy in Angular? When Angular uses *ngFor to loop over a list, it re-renders the entire list whenever the array changes—even if only one item changed. This can cause: ❌ Unnecessary...
⭐ What Is Attribute Binding (attr) in Angular? Attribute binding in Angular lets you set HTML attributes dynamically using data from your component. Syntax:
|
1 |
[attr.attributeName]="value" |
Example:
|
1 |
<td [attr.colspan]="2"></td> |
You use attr. because not all...
⭐ What Are Pipes in Angular? A Pipe in Angular is a tool used in templates to transform or format data before displaying it to the user. You apply a pipe using the pipe...
⭐ What Are Template Statements in Angular? A template statement is the code you write inside ()` parentheses to respond to user events in HTML. For example:
|
1 |
<button (click)="onClick()">Click Me</button> |
Here: (click) → event binding “onClick()”...
⭐ What is ngTemplateOutlet? ngTemplateOutlet is an Angular directive that allows you to insert (render) an <ng-template> dynamically wherever you want. It helps you: ✔ Reuse templates✔ Show templates conditionally✔ Pass context data into...
⭐ What Are Structural Directives in Angular? Structural directives change or control the structure of the DOM. Examples: *ngIf *ngFor *ngSwitchCase They all use micro-syntax, a special shorthand language inside templates. 🎯 What is...
⭐ What is Null-Safe Navigation (?.) in Angular Templates? The null-safe navigation operator (?.) is used in Angular templates to safely access properties of objects that might be null or undefined. It prevents the...
🎯 What Are Template Reference Variables in Angular? A Template Reference Variable is a variable created in an Angular template (HTML) using #variableName. It gives you direct access to an element, component, or directive...
🎯 What is Interpolation in Angular? Interpolation is a technique in Angular templates that allows you to display data from your component class into the HTML view. It uses the double curly braces: {{...
⭐ What Are Angular Templates? An Angular Template is the HTML code that defines the view of a component. It is where you: Display data Handle user events Use Angular directives Bind expressions Every...