-
Notifications
You must be signed in to change notification settings - Fork 27k
feat(core): add support for let syntax #56715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Enables the new `@let` syntax by default. `@let` declarations are defined as: 1. The `@let` keyword. 2. Followed by one or more whitespaces. 3. Followed by a valid JavaScript name and zero or more whitespaces. 4. Followed by the `=` symbol and zero or more whitespaces. 5. Followed by an Angular expression which can be multi-line. 6. Terminated by the `;` symbol. Example usage: ``` @let user = user$ | async; @let greeting = user ? 'Hello, ' + user.name : 'Loading'; <h1>{{greeting}}</h1> ``` Fixes angular#15280.
|
This PR was merged into the repository by commit 0a48d58. The changes were merged into the following branches: main |
|
I have a question on this if its ok here. With using myInput() several times like myModel().someLoop myModel().options.hideOnClose, will let improve „getting“ the value or does it make no performance differences in doing a @let = myModel()? |
|
If you do |
So this isn't template computed right? Just a variable assignment. Is there any future plans to support template computed? |
|
The plan is to eventually have it be like
|
|
That wasnt what I meant. Will multiple myModel() calls in the template infect the performance or will do one |
|
Made an example what I meant: https://stackblitz.com/edit/stackblitz-starters-mnwyqx?file=src%2Fmain.ts |
A signal will always return its latest value (this applies to signals and computed signals) unless a dependency of a computed changed. In this sense those are "smart getters" and definitively help with performance of expensive computations.
It will be one call. The performance benefits will be getting bigger as you've got more calls to myModel() and calls to |
|
What is about scope of visibility of @let variable? As I understand from above named block creates scope of visibility, ng-template also creates scope of visibility, but other markup elements don't. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Enables the new
@letsyntax by default.@letdeclarations are defined as:@letkeyword.=symbol and zero or more whitespaces.;symbol.Example usage:
Fixes #15280.