feat(core): separate refs from vars.

Introduces `ref-` to give a name to an element or a directive (also works for `<template>` elements), and `let-` to introduce an input variable for a `<template>` element.

BREAKING CHANGE:
- `#...` now always means `ref-`.
- `<template #abc>` now defines a reference to the TemplateRef, instead of an input variable used inside of the template.
- `#...` inside of a *ngIf, … directives is deprecated.
  Use `let …` instead.
- `var-...` is deprecated. Replace with `let-...` for `<template>` elements and `ref-` for non `<template>` elements.

Closes #7158

Closes #8264
This commit is contained in:
Tobias Bosch
2016-04-25 19:52:24 -07:00
parent ff2ae7a2e1
commit d2efac18ed
69 changed files with 651 additions and 414 deletions

View File

@ -14,7 +14,7 @@ Removes or recreates a portion of the DOM tree based on the showSection expressi
@cheatsheetItem
syntax:
`<li *ngFor="#item of list">`|`*ngFor`
`<li *ngFor="let item of list">`|`*ngFor`
description:
Turns the li element and its contents into a template, and uses that to instantiate a view for each item in list.

View File

@ -433,7 +433,7 @@ Finally, we can move the `ngFor` keyword to the left hand side and prefix it wit
```
<ul>
<li *ngFor="var person of people; var i=index">{{i}}. {{person}}<li>
<li *ngFor="let person of people; var i=index">{{i}}. {{person}}<li>
</ul>
```

View File

@ -94,7 +94,7 @@ Let's start with a View such as:
```
<ul>
<li template="ngFor: #person of people">{{person}}</li>
<li template="ngFor: let person of people">{{person}}</li>
</ul>
```