diff --git a/modules/angular2/src/core/linker/element.ts b/modules/angular2/src/core/linker/element.ts
index 7911e35c60..b61ea3a231 100644
--- a/modules/angular2/src/core/linker/element.ts
+++ b/modules/angular2/src/core/linker/element.ts
@@ -463,7 +463,11 @@ export class AppElement implements DependencyProvider, ElementRef, AfterViewChec
var inj: AppElement = this;
while (isPresent(inj)) {
inj._setQueriesAsDirty();
- inj = inj.parent;
+ if (isBlank(inj.parent) && isPresent(inj.parentView.containerAppElement)) {
+ inj = inj.parentView.containerAppElement;
+ } else {
+ inj = inj.parent;
+ }
}
}
diff --git a/modules/angular2/test/core/linker/query_integration_spec.ts b/modules/angular2/test/core/linker/query_integration_spec.ts
index 33f64998ae..d2a454127c 100644
--- a/modules/angular2/test/core/linker/query_integration_spec.ts
+++ b/modules/angular2/test/core/linker/query_integration_spec.ts
@@ -140,6 +140,35 @@ export function main() {
});
}));
+ it('should contain the first view child accross embedded views',
+ inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
+ var template = '