angular-cn/packages/core/schematics/migrations/template-var-assignment
Paul Gschwendtner 364250e7a6 refactor(core): static-query migration should not fail for test files (#30034)
Currently when someone runs `ng update` with the static-query migration,
the migration can fail with an error saying that the `AOT` compiler could not
be created. This can happen if the CLI project contains a test `tsconfig.json`
that is picked up by the schematic.

Due to the fact that spec tsconfig files cannot be ran with NGC (e.g. test
components are not part of a module; not all source files are guaranteed to
be included), test `tsconfig` projects will now use a new `test` migration
strategy where all queries within tests are left untouched and a TODO is added.

PR Close #30034
2019-04-23 08:32:35 -07:00
..
angular refactor(core): template-var-assignment migration incorrectly warns (#30026) 2019-04-22 11:16:19 -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
README.md
analyze_template.ts refactor(core): template-var-assignment migration incorrectly warns (#30026) 2019-04-22 11:16:19 -07:00
index.ts refactor(core): static-query migration should not fail for test files (#30034) 2019-04-23 08:32:35 -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>