fix(core): require 'static' flag on queries in typings (#30639)

This commit makes the static flag on @ViewChild and @ContentChild required.

BREAKING CHANGE:

In Angular version 8, it's required that all @ViewChild and @ContentChild
queries have a 'static' flag specifying whether the query is 'static' or
'dynamic'. The compiler previously sorted queries automatically, but in
8.0 developers are required to explicitly specify which behavior is wanted.
This is a temporary requirement as part of a migration; see
https://angular.io/guide/static-query-migration for more details.

@ViewChildren and @ContentChildren queries are always dynamic, and so are
unaffected.

PR Close #30639
This commit is contained in:
Alex Rickabaugh
2019-05-23 11:31:10 -07:00
committed by Matias Niemelä
parent dc6406e5e8
commit 84dd2679a9
21 changed files with 46 additions and 45 deletions

View File

@ -10,18 +10,16 @@ declare var System: any;
`,
})
export class AppComponent implements AfterViewInit {
@ViewChild('vc', {read: ViewContainerRef}) container: ViewContainerRef;
@ViewChild('vc', {read: ViewContainerRef, static: false}) container: ViewContainerRef;
constructor(private compiler: Compiler) {
}
constructor(private compiler: Compiler) {}
ngAfterViewInit() {
System.import('./dist/lazy.bundle.js').then((module: any) => {
this.compiler.compileModuleAndAllComponentsAsync(module.LazyModule)
.then((compiled) => {
const factory = compiled.componentFactories[0];
this.container.createComponent(factory);
});
this.compiler.compileModuleAndAllComponentsAsync(module.LazyModule).then((compiled) => {
const factory = compiled.componentFactories[0];
this.container.createComponent(factory);
});
});
}
}