import {isPresent} from 'angular2/src/facade/lang';
import * as viewModule from './view';
import {RenderViewRef} from 'angular2/src/render/api';
// This is a workaround for privacy in Dart as we don't have library parts
export function internalView(viewRef: ViewRef): viewModule.AppView {
return viewRef._view;
}
// This is a workaround for privacy in Dart as we don't have library parts
export function internalProtoView(protoViewRef: ProtoViewRef): viewModule.AppProtoView {
return isPresent(protoViewRef) ? protoViewRef._protoView : null;
}
/**
* A reference to an Angular View.
*
* A View is a fundamental building block of Application UI. A View is the smallest set of
* elements which are created and destroyed together. A View can change properties on the elements
* within the view, but it can not change the structure of those elements.
*
* To change structure of the elements, the Views can contain zero or more {@link ViewContainerRef}s
* which allow the views to be nested.
*
* ## Example
*
* Given this template
*
* ```
* Count: {{items.length}}
*
* ```
*
* The above example we have two {@link ProtoViewRef}s:
*
* Outter {@link ProtoViewRef}:
* ```
* Count: {{items.length}}
*
* ```
*
* Inner {@link ProtoViewRef}:
* ```
* {{item}}
* ```
*
* Notice that the original template is broken down into two separate {@link ProtoViewRef}s.
*
* The outter/inner {@link ProtoViewRef}s are then assembled into views like so:
*
* ```
*
* Count: 2
*
*
* ```
*/
export class ViewRef {
constructor(public _view: viewModule.AppView) {}
/**
* Return {@link RenderViewRef}
*/
get render(): RenderViewRef { return this._view.render; }
/**
* Set local variable for a view.
*
*
*/
setLocal(contextName: string, value: any): void { this._view.setLocal(contextName, value); }
}
/**
* A reference to an Angular ProtoView.
*
* A ProtoView is a reference to a template for easy creation of views.
* (See {@link AppViewManager#createViewInContainer} and {@link AppViewManager#createRootHostView}).
*
* A `ProtoView` is a foctary for creating `View`s.
*
* ## Example
*
* Given this template
*
* ```
* Count: {{items.length}}
*
* ```
*
* The above example we have two {@link ProtoViewRef}s:
*
* Outter {@link ProtoViewRef}:
* ```
* Count: {{items.length}}
*
* ```
*
* Inner {@link ProtoViewRef}:
* ```
* {{item}}
* ```
*
* Notice that the original template is broken down into two separate {@link ProtoViewRef}s.
*/
export class ProtoViewRef {
/**
* @private
*/
constructor(public _protoView: viewModule.AppProtoView) {}
}