refactor(views): split ViewManager/ViewContainerRef.createView into 2 methods

BREAKING CHANGES:

`ViewManager.createView` / `ViewContainerRef.create` have been split into 2 methods:

- `createHostView` which takes dynamically created bindings
- `createEmbeddedView` which takes the newly introduced `TemplateRef`

The new type `TemplateRef` is the combination of a `ProtoViewRef` and and `ElementRef`
from the same place. Use `TemplateRef` when working with embedded views in
`ng-if`, `ng-for`, ... instead of `ProtoViewRef`.

Also, `ProtoViewRef` is no more injectable, but `TemplateRef` is.

First part of #1989 to clean up manual content projection.
Closes #3114
This commit is contained in:
Tobias Bosch
2015-07-17 10:40:32 -07:00
parent 762a94f2cd
commit f42382db3b
17 changed files with 198 additions and 126 deletions
@@ -360,12 +360,12 @@ import {DEFAULT} from 'angular2/change_detection';
* })
* export class Unless {
* viewContainer: ViewContainerRef;
* protoViewRef: ProtoViewRef;
* templateRef: TemplateRef;
* prevCondition: boolean;
*
* constructor(viewContainer: ViewContainerRef, protoViewRef: ProtoViewRef) {
* constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef) {
* this.viewContainer = viewContainer;
* this.protoViewRef = protoViewRef;
* this.templateRef = templateRef;
* this.prevCondition = null;
* }
*
@@ -375,7 +375,7 @@ import {DEFAULT} from 'angular2/change_detection';
* this.viewContainer.clear();
* } else if (!newCondition && (isBlank(this.prevCondition) || this.prevCondition)) {
* this.prevCondition = false;
* this.viewContainer.create(this.protoViewRef);
* this.viewContainer.create(this.templateRef);
* }
* }
* }