tools/manual_api_docs/blocks/let.md
@let allows you to define a local variable and re-use it across the template.
@let name = user.name;
@let data = data$ | async;
@let declarations are similar to JavaScript's let and
their values can be any valid Angular expression. The expressions will be re-evaluated everytime the template is executed.
Similarly to JavaScript variables, variables declared with @let, can be used:
@let user = user$ | async;
@if (user) {
<h1>Hello, {{user.name}}</h1>
<user-avatar [photo]="user.photo"/>
<ul>
@for (snack of user.favoriteSnacks; track snack.id) {
<li>{{snack.name}}</li>
}
</ul>
<button (click)="update(user)">Update profile</button>
}
The @let syntax is formally defined as:
@let keyword.; symbol.HELPFUL: A comprehensive description of the feature is available on the templates guide