diff --git a/modules/@angular/core/src/linker/view_container_ref.ts b/modules/@angular/core/src/linker/view_container_ref.ts index d21ff0f669..947f8a1dc1 100644 --- a/modules/@angular/core/src/linker/view_container_ref.ts +++ b/modules/@angular/core/src/linker/view_container_ref.ts @@ -186,7 +186,8 @@ export class ViewContainerRef_ implements ViewContainerRef { } indexOf(viewRef: ViewRef): number { - return this._element.nestedViews.indexOf((>viewRef).internalView); + return this.length ? this._element.nestedViews.indexOf((>viewRef).internalView) : + -1; } /** @internal */ @@ -213,7 +214,7 @@ export class ViewContainerRef_ implements ViewContainerRef { return wtfLeave(s, view.ref); } - clear() { + clear(): void { for (let i = this.length - 1; i >= 0; i--) { this.remove(i); }