forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate_ref.ts
More file actions
32 lines (27 loc) · 1002 Bytes
/
template_ref.ts
File metadata and controls
32 lines (27 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import {internalView, ProtoViewRef} from './view_ref';
import {ElementRef} from './element_ref';
import * as viewModule from './view';
/**
* Reference to a template within a component.
*
* Represents an opaque reference to the underlying template that can
* be instantiated using the {@link ViewContainerRef}.
*/
export class TemplateRef {
/**
* The location of the template
*/
elementRef: ElementRef;
constructor(elementRef: ElementRef) { this.elementRef = elementRef; }
private _getProtoView(): viewModule.AppProtoView {
var parentView = internalView(this.elementRef.parentView);
return parentView.proto
.elementBinders[this.elementRef.boundElementIndex - parentView.elementOffset]
.nestedProtoView;
}
get protoViewRef(): ProtoViewRef { return this._getProtoView().ref; }
/**
* Whether this template has a local variable with the given name
*/
hasLocal(name: string): boolean { return this._getProtoView().variableBindings.has(name); }
}