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
Attribute two way binding not working with $any and error is unclear #51165
changed the title [-]ngModel two way binding not works with $any and error is unclear[/-][+]ngModel two way binding not working with `$any` and error is unclear[/+]on Jul 25, 2023
But this is easy example, in my main project i have more unclear errors (this is actually why i created this issue, i understand how to resolve my issue, but it take a while and really is a bug):
And if first two errors make sense, further errors appears on completely good lines e.g: <comments-card [targetID]="value?.id" [entityType]="getEntityType()"></comments-card>
It starts to hate every '=' after the place where i had [(attribute)]="$any(...)".
But i can't reproduce that very bad case and can't share my production code.
When i separated [(attribute)] into [attribute] and (attributeChange) in single place the hundreds of Unexpected token '=' errors disappeared.
Sorry i checked it was because of my custom attribute, not ngModel
changed the title [-]ngModel two way binding not working with `$any` and error is unclear[/-][+]Attribute two way binding not working with `$any` and error is unclear[/+]on Jul 25, 2023
I have solve your issue in the above stackblitz link but the way you want to do the problem is not a well practice and good approach to do it.
Question:
why you want to use the $any with the two way binding directive?
If you really want to assign the any to the type-members in angular then just when initilizing the type-member assign the "any" type there but still not recommended to assign that type because it makes occuption memory alot and also reading the code become more complex.
Also do not use the $any type with the ngModel (two way binding) because it is not a valid approach to do that. just simply make the normal property and assign its reference. name: string = 'Angular'; <input [(ngModel)]="name" />
@AbobakarSadeeq I understand that i can't use $any with two way binding and i understand how to solve a problem, but error message should be more clear, because in one case it was completely wrong - "error NG5002: Parser Error: Unexpected token '='", and it's hard to find culprit because compiler reports first place where wrong two-way binding met and further places where it met '=' symbol (correct bindings). I thought that i reproduced that issue, but on my stackblitz error was different: Parser Error: Unexpected token '=' at column 12 in [$any(name) =$event] in /~/src/main.ts@11:24 (it works as exptected and doesn't report further '=' symbols as unexpected tokens.
Activity
[-]ngModel two way binding not works with $any and error is unclear[/-][+]ngModel two way binding not working with `$any` and error is unclear[/+]roma2341 commentedon Jul 25, 2023
But this is easy example, in my main project i have more unclear errors (this is actually why i created this issue, i understand how to resolve my issue, but it take a while and really is a bug):
And if first two errors make sense, further errors appears on completely good lines e.g:
<comments-card [targetID]="value?.id" [entityType]="getEntityType()"></comments-card>It starts to hate every '=' after the place where i had [(attribute)]="$any(...)".
But i can't reproduce that very bad case and can't share my production code.
When i separated [(attribute)] into [attribute] and (attributeChange) in single place the hundreds of Unexpected token '=' errors disappeared.
Sorry i checked it was because of my custom attribute, not ngModel
[-]ngModel two way binding not working with `$any` and error is unclear[/-][+]Attribute two way binding not working with `$any` and error is unclear[/+]roma2341 commentedon Jul 25, 2023
You can remove this issue, i can't reproduce what i really want to reproduce =(
AbobakarSadeeq commentedon Jul 26, 2023
Here is the solution:
https://stackblitz.com/edit/angular-hxyrrs?file=src%2Fmain.html,src%2Fmain.ts
I have solve your issue in the above stackblitz link but the way you want to do the problem is not a well practice and good approach to do it.
Question:
If you really want to assign the any to the type-members in angular then just when initilizing the type-member assign the "any" type there but still not recommended to assign that type because it makes occuption memory alot and also reading the code become more complex.
Also do not use the $any type with the ngModel (two way binding) because it is not a valid approach to do that. just simply make the normal property and assign its reference.
name: string = 'Angular';<input [(ngModel)]="name" />roma2341 commentedon Jul 26, 2023
@AbobakarSadeeq I understand that i can't use $any with two way binding and i understand how to solve a problem, but error message should be more clear, because in one case it was completely wrong - "error NG5002: Parser Error: Unexpected token '='", and it's hard to find culprit because compiler reports first place where wrong two-way binding met and further places where it met '=' symbol (correct bindings). I thought that i reproduced that issue, but on my stackblitz error was different:
Parser Error: Unexpected token '=' at column 12 in [$any(name) =$event] in /~/src/main.ts@11:24(it works as exptected and doesn't report further '=' symbols as unexpected tokens.alxhub commentedon Mar 29, 2024
The error is at least better now:
$anyshould work, though. Tagging this as a compiler bug.fix(compiler): allow $any in two-way bindings
fix(compiler): allow $any in two-way bindings (angular#59362)
angular-automatic-lock-bot commentedon Feb 6, 2025
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.
fix(compiler): allow $any in two-way bindings (angular#59362)