angular-cn/packages/core/schematics/migrations/template-var-assignment
Paul Gschwendtner b0c1282fbe refactor(core): migrations do not properly handle multiple templates in source file (#29841)
Currently if there are multiple source files within a given
TypeScript source file, only the last template in the source
file is checked as we store templates in a `Map` with the
source file paths as keys.

This is problematic as multiple templates can live within the
same source file and we therefore accidentally overwrite
existing entries in the resolved templates map.

PR Close #29841
2019-04-15 11:13:39 -07:00
..
angular refactor(core): move schematic component template visitor to utils (#29713) 2019-04-11 08:22:44 -07:00
google3 refactor(core): migrations do not properly handle multiple templates in source file (#29841) 2019-04-15 11:13:39 -07:00
BUILD.bazel feat(core): template-var-assignment update schematic (#29608) 2019-04-02 15:47:32 -07:00
README.md refactor(core): polish failure messages for template-var-assignment schematic (#29708) 2019-04-08 09:46:57 -07:00
analyze_template.ts refactor(core): migrations do not properly handle multiple templates in source file (#29841) 2019-04-15 11:13:39 -07:00
index.ts refactor(core): migrations do not properly handle multiple templates in source file (#29841) 2019-04-15 11:13:39 -07:00

README.md

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>