refactor(core): removed getter and changed to readonly variable (#19117)

PR Close #19117
This commit is contained in:
Yuan Gao
2017-09-08 18:06:33 -07:00
committed by Igor Minar
parent 549f2254b4
commit b14c2d1568
9 changed files with 62 additions and 77 deletions

View File

@ -101,18 +101,21 @@ class ComponentFactory_ extends ComponentFactory<any> {
}
class ComponentRef_ extends ComponentRef<any> {
public readonly hostView: ViewRef;
public readonly instance: any;
public readonly changeDetectorRef: ChangeDetectorRef;
private _elDef: NodeDef;
constructor(private _view: ViewData, private _viewRef: ViewRef, private _component: any) {
super();
this._elDef = this._view.def.nodes[0];
this.hostView = _viewRef;
this.changeDetectorRef = _viewRef;
this.instance = _component;
}
get location(): ElementRef {
return new ElementRef(asElementData(this._view, this._elDef.index).renderElement);
}
get injector(): Injector { return new Injector_(this._view, this._elDef); }
get instance(): any { return this._component; };
get hostView(): ViewRef { return this._viewRef; };
get changeDetectorRef(): ChangeDetectorRef { return this._viewRef; };
get componentType(): Type<any> { return <any>this._component.constructor; }
destroy(): void { this._viewRef.destroy(); }