You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using this keyword in templates will use template varibales instead of component variables. #55115
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
No
Description
When defining a variable inside of a template (for example setting a variable with $index in a loop), using this. in combination with that variable will resolve to the local template variable and not the component variable.
@Component({selector: "app",standalone: true,template: ` @for (item of list; track item; let idx = $index) { {{ this.idx }} {{ item }} } `,})exportclassApp{publiclist=["hello"];publicidx="this should be idx";}
This shows 0 hello instead of this should be idx hello.
Please provide a link to a minimal reproduction of the bug
We noticed this by accident, obviously not a show-stopper, we just have a co-worker who's convinced he should use the this keyword in templates and doesn't want to stop.
IIRC this is not a regression -- in fact, we deliberately reimplemented this bug in Template Pipeline to avoid breaking applications. Now that TemplateDefinitionBuilder is deleted, it might be time to try fixing this for good, and get a sense of how breaking that change would be.
Activity
crisbeto commentedon Mar 29, 2024
Looks like this came up when the pipeline was being implemented: https://github.com/angular/angular/blob/main/packages/compiler/src/template/pipeline/src/ingest.ts#L729.
dylhunn commentedon Apr 2, 2024
IIRC this is not a regression -- in fact, we deliberately reimplemented this bug in Template Pipeline to avoid breaking applications. Now that
TemplateDefinitionBuilderis deleted, it might be time to try fixing this for good, and get a sense of how breaking that change would be.2 remaining items
fix(compiler): `this.a` should always refer to class property `a`
fix(compiler): `this.a` should always refer to class property `a` (an…
angular-automatic-lock-bot commentedon Nov 8, 2024
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.