
Currently the `template-var-assignment` migration incorrectly warns if the template writes to a property in the component that has the same `ast.PropertyWrite´ name as a template input variable but different receiver. e.g. ```html <!-- "someProp.element" will be incorrectly reported as template variable assignment --> <button *ngFor="let element of list" (click)="someProp.element = null">Reset</button> ``` Similarly if an output writes to a component property with the same name as a template input variable, but the expression is within a different template scope, the schematic currently incorrectly warns. e.g. ```html <button *ngFor="let element of list">{{element}}</button> <!-- The "element = null" expression does not refer to the "element" template input variable --> <button (click)="element = null"></button> ``` PR Close #30026
Assignments to template variables
With Ivy, assignments to template variables are no longer supported as template variables are effectively constants.
This means that assignments to template variables will break your application once Ivy is enabled by default. For example:
<button *ngFor="let option of options"
(click)="option = 'newButtonText'">
{{ option }}
</button>
In the example from above, a value is assigned to the option
template variable on click
. This will ultimately break your
application and therefore the logic needs to be adjusted to not
update the option
variable, but rather the given element in
the options
array:
<button *ngFor="let option of options; let idx = index"
(click)="options[idx] = 'newButtonText'">
{{ option }}
</button>