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:
@ -82,7 +82,7 @@ class DataService {
|
||||
selector: 'order-list-cmp',
|
||||
template: `
|
||||
<h1>Orders</h1>
|
||||
<div *ngFor="#order of orders" [class.warning]="order.total > order.limit">
|
||||
<div *ngFor="let order of orders" [class.warning]="order.total > order.limit">
|
||||
<div>
|
||||
<label>Customer name:</label>
|
||||
{{order.customerName}}
|
||||
@ -173,7 +173,7 @@ class OrderItemComponent {
|
||||
|
||||
<h2>Items</h2>
|
||||
<button (click)="addItem()">Add Item</button>
|
||||
<order-item-cmp *ngFor="#item of order.items" [item]="item" (delete)="deleteItem(item)"></order-item-cmp>
|
||||
<order-item-cmp *ngFor="let item of order.items" [item]="item" (delete)="deleteItem(item)"></order-item-cmp>
|
||||
</div>
|
||||
`,
|
||||
directives: [FORM_DIRECTIVES, OrderItemComponent, NgFor, NgIf]
|
||||
|
Reference in New Issue
Block a user