refactor(core): polish failure messages for template-var-assignment schematic (#29708)

Improves the failure messages for the `template-var-assignment` schematic. After manual
testing of the schematic it's not quite clear for developers what the failure message means
without any context. The schematic now also references a short markdown file mentioning
what needs to be changed, but eventually this document needs to be expanded with more
information and context of the reasoning behind this change within Ivy.

PR Close #29708
This commit is contained in:
Paul Gschwendtner
2019-04-04 12:52:29 +02:00
committed by Igor Minar
parent 8bbf481d60
commit 4a2fb86b1e
3 changed files with 64 additions and 18 deletions

View File

@ -0,0 +1,27 @@
## 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:
```html
<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:
```html
<button *ngFor="let option of options; let idx = index"
(click)="options[idx] = 'newButtonText'">
{{ option }}
</button>
```