Angular
What’s new of Angular 17?
New built-in control flow
@if
<div *ngIf="condition; else elseBlock"> Content to render when condition is true. </div> <ng-template #elseBlock> Content to render when condition is false. </ng-template>
@if (a > b) { {{a}} is greater than {{b}} } @else if (b > a) { {{a}} is less than {{b}} } @else { {{a}} is equal to {{b}} }
@for
<li *ngFor="let user of users; index as i; first as isFirst"> {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span> </li>
@for (item of items; track item.id) { {{ item.name }} } @for (item of items; track item.id; let idx = $index, e = $even) { Item #{{ idx }}: {{ item.name }} }
Inside @for contents, several implicit variables are always available:
-
$count Number of items in a collection iterated over
-
$index Index of the current row
-
$first Whether the current row is the first row
-
$last Whether the current row is the last row
-
$even Whether the current row index is even
-
$odd Whether the current row index is odd
Angular Signal
Basically Angular signal is a special type of variable that holds a value and also provides a notification mechanism to tell other program when the variable changes.
-
signal() - Create a signal
-
computed() - Create a computed signal from another signal
-
effect() - Create an effect call back when signal value changed
-
input() - Create an input prop
-
output() - Create an output prop
-
model() - Create a model signal prop, which is writable