test: clean up explicit dynamic query usages (#33015)

Cleans up all the places where we explicitly set `static: false` on queries.

PR Close #33015
This commit is contained in:
crisbeto 2019-10-05 10:04:54 +02:00 committed by Matias Niemelä
parent 7e64bbe5a8
commit 9d54679e66
46 changed files with 273 additions and 279 deletions

View File

@ -8,7 +8,7 @@ import { Component, ViewChild, ElementRef } from '@angular/core';
}) })
export class AppComponent { export class AppComponent {
@ViewChild('bindingInput', { static: false }) bindingInput: ElementRef; @ViewChild('bindingInput') bindingInput: ElementRef;
isUnchanged = true; isUnchanged = true;

View File

@ -39,7 +39,7 @@ export class CountdownLocalVarParentComponent { }
}) })
export class CountdownViewChildParentComponent implements AfterViewInit { export class CountdownViewChildParentComponent implements AfterViewInit {
@ViewChild(CountdownTimerComponent, {static: false}) @ViewChild(CountdownTimerComponent)
private timerComponent: CountdownTimerComponent; private timerComponent: CountdownTimerComponent;
seconds() { return 0; } seconds() { return 0; }

View File

@ -34,7 +34,7 @@ export class AfterContentComponent implements AfterContentChecked, AfterContentI
comment = ''; comment = '';
// Query for a CONTENT child of type `ChildComponent` // Query for a CONTENT child of type `ChildComponent`
@ContentChild(ChildComponent, {static: false}) contentChild: ChildComponent; @ContentChild(ChildComponent) contentChild: ChildComponent;
// #enddocregion hooks // #enddocregion hooks
constructor(private logger: LoggerService) { constructor(private logger: LoggerService) {

View File

@ -35,7 +35,7 @@ export class AfterViewComponent implements AfterViewChecked, AfterViewInit {
private prevHero = ''; private prevHero = '';
// Query for a VIEW child of type `ChildViewComponent` // Query for a VIEW child of type `ChildViewComponent`
@ViewChild(ChildViewComponent, {static: false}) viewChild: ChildViewComponent; @ViewChild(ChildViewComponent) viewChild: ChildViewComponent;
// #enddocregion hooks // #enddocregion hooks
constructor(private logger: LoggerService) { constructor(private logger: LoggerService) {

View File

@ -81,7 +81,7 @@ export class DoCheckParentComponent {
hero: Hero; hero: Hero;
power: string; power: string;
title = 'DoCheck'; title = 'DoCheck';
@ViewChild(DoCheckComponent, {static: false}) childView: DoCheckComponent; @ViewChild(DoCheckComponent) childView: DoCheckComponent;
constructor() { this.reset(); } constructor() { this.reset(); }

View File

@ -55,7 +55,7 @@ export class OnChangesParentComponent {
hero: Hero; hero: Hero;
power: string; power: string;
title = 'OnChanges'; title = 'OnChanges';
@ViewChild(OnChangesComponent, {static: false}) childView: OnChangesComponent; @ViewChild(OnChangesComponent) childView: OnChangesComponent;
constructor() { constructor() {
this.reset(); this.reset();

View File

@ -8,7 +8,7 @@ import { NgForm } from '@angular/forms';
styleUrls: ['./app.component.css'] styleUrls: ['./app.component.css']
}) })
export class AppComponent { export class AppComponent {
@ViewChild('itemForm', { static: false }) form: NgForm; @ViewChild('itemForm') form: NgForm;
private _submitMessage = ''; private _submitMessage = '';

View File

@ -13,7 +13,7 @@ import { Hero } from './hero';
}) })
export class HeroFormComponent { export class HeroFormComponent {
@Input() hero: Hero; @Input() hero: Hero;
@ViewChild('heroForm', {static: false}) form: NgForm; @ViewChild('heroForm') form: NgForm;
// tslint:disable-next-line:variable-name // tslint:disable-next-line:variable-name
private _submitMessage = ''; private _submitMessage = '';

View File

@ -6,7 +6,7 @@ import { Component, AfterViewInit, ViewChild, ElementRef } from '@angular/core';
}) })
export class CanvasComponent implements AfterViewInit { export class CanvasComponent implements AfterViewInit {
blobSize: number; blobSize: number;
@ViewChild('sampleCanvas', {static: false}) sampleCanvas: ElementRef; @ViewChild('sampleCanvas') sampleCanvas: ElementRef;
constructor() { } constructor() { }

View File

@ -10,7 +10,7 @@ declare var System: any;
`, `,
}) })
export class AppComponent implements AfterViewInit { export class AppComponent implements AfterViewInit {
@ViewChild('vc', {read: ViewContainerRef, static: false}) container: ViewContainerRef; @ViewChild('vc', {read: ViewContainerRef}) container: ViewContainerRef;
constructor(private compiler: Compiler) {} constructor(private compiler: Compiler) {}

View File

@ -48,7 +48,7 @@ export class ExpandingRowSummary implements OnDestroy {
* reference to compute collapsed height of the row. We also use this * reference to compute collapsed height of the row. We also use this
* reference for focus and blur methods below. * reference for focus and blur methods below.
*/ */
@ViewChild('expandingRowSummaryMainElement', {static: false}) @ViewChild('expandingRowSummaryMainElement')
mainElementRef !: ElementRef; mainElementRef !: ElementRef;
/** Subscription for changes in parent isExpanded property. */ /** Subscription for changes in parent isExpanded property. */

View File

@ -1622,7 +1622,7 @@ describe('compiler compliance', () => {
}) })
export class ViewQueryComponent { export class ViewQueryComponent {
@ViewChild(SomeDirective, {static: true}) someDir !: SomeDirective; @ViewChild(SomeDirective, {static: true}) someDir !: SomeDirective;
@ViewChild('foo', {static: false}) foo !: ElementRef; @ViewChild('foo') foo !: ElementRef;
} }
@NgModule({declarations: [SomeDirective, ViewQueryComponent]}) @NgModule({declarations: [SomeDirective, ViewQueryComponent]})
@ -1740,7 +1740,7 @@ describe('compiler compliance', () => {
\` \`
}) })
export class ContentQueryComponent { export class ContentQueryComponent {
@ContentChild(SomeDirective, {static: false}) someDir: SomeDirective; @ContentChild(SomeDirective) someDir: SomeDirective;
@ContentChildren(SomeDirective) someDirList !: QueryList<SomeDirective>; @ContentChildren(SomeDirective) someDirList !: QueryList<SomeDirective>;
} }
@ -1809,7 +1809,7 @@ describe('compiler compliance', () => {
\` \`
}) })
export class ContentQueryComponent { export class ContentQueryComponent {
@ContentChild('myRef', {static: false}) myRef: any; @ContentChild('myRef') myRef: any;
@ContentChildren('myRef1, myRef2, myRef3') myRefs: QueryList<any>; @ContentChildren('myRef1, myRef2, myRef3') myRefs: QueryList<any>;
} }
@NgModule({declarations: [ContentQueryComponent]}) @NgModule({declarations: [ContentQueryComponent]})
@ -1860,7 +1860,7 @@ describe('compiler compliance', () => {
}) })
export class ContentQueryComponent { export class ContentQueryComponent {
@ContentChild(SomeDirective, {static: true}) someDir !: SomeDirective; @ContentChild(SomeDirective, {static: true}) someDir !: SomeDirective;
@ContentChild('foo', {static: false}) foo !: ElementRef; @ContentChild('foo') foo !: ElementRef;
} }
@Component({ @Component({
@ -1931,9 +1931,9 @@ describe('compiler compliance', () => {
\` \`
}) })
export class ContentQueryComponent { export class ContentQueryComponent {
@ContentChild('myRef', {read: TemplateRef, static: false}) myRef: TemplateRef; @ContentChild('myRef', {read: TemplateRef}) myRef: TemplateRef;
@ContentChildren('myRef1, myRef2, myRef3', {read: ElementRef}) myRefs: QueryList<ElementRef>; @ContentChildren('myRef1, myRef2, myRef3', {read: ElementRef}) myRefs: QueryList<ElementRef>;
@ContentChild(SomeDirective, {read: ElementRef, static: false}) someDir: ElementRef; @ContentChild(SomeDirective, {read: ElementRef}) someDir: ElementRef;
@ContentChildren(SomeDirective, {read: TemplateRef}) someDirs: QueryList<TemplateRef>; @ContentChildren(SomeDirective, {read: TemplateRef}) someDirs: QueryList<TemplateRef>;
} }
@NgModule({declarations: [ContentQueryComponent]}) @NgModule({declarations: [ContentQueryComponent]})
@ -3210,7 +3210,7 @@ describe('compiler compliance', () => {
'spec.ts': ` 'spec.ts': `
import {Component, NgModule, ContentChild} from '@angular/core'; import {Component, NgModule, ContentChild} from '@angular/core';
export class BaseClass { export class BaseClass {
@ContentChild('something', {static: false}) something: any; @ContentChild('something') something: any;
} }
@Component({ @Component({

View File

@ -1094,7 +1094,7 @@ runInEachFileSystem(os => {
template: '<ng-content></ng-content>' template: '<ng-content></ng-content>'
}) })
export class TestCmp { export class TestCmp {
@Input() @ContentChild('foo', {static: false}) foo: any; @Input() @ContentChild('foo') foo: any;
} }
`); `);
@ -1116,7 +1116,7 @@ runInEachFileSystem(os => {
}) })
export class TestCmp { export class TestCmp {
@ContentChild('bar', {static: true}) @ContentChild('bar', {static: true})
@ContentChild('foo', {static: false}) @ContentChild('foo')
foo: any; foo: any;
} }
`); `);
@ -1138,7 +1138,7 @@ runInEachFileSystem(os => {
template: '...' template: '...'
}) })
export class TestCmp { export class TestCmp {
@ContentChild('foo', {static: false}) @ContentChild('foo')
private someFn() {} private someFn() {}
} }
`); `);
@ -1653,10 +1653,10 @@ runInEachFileSystem(os => {
} }
}) })
class FooCmp { class FooCmp {
@ContentChild('bar', {read: TemplateRef, static: false}) child: any; @ContentChild('bar', {read: TemplateRef}) child: any;
@ContentChildren(TemplateRef) children: any; @ContentChildren(TemplateRef) children: any;
get aview(): any { return null; } get aview(): any { return null; }
@ViewChild('accessor', {static: false}) set aview(value: any) {} @ViewChild('accessor') set aview(value: any) {}
} }
`); `);
@ -1684,7 +1684,7 @@ runInEachFileSystem(os => {
} }
}) })
class FooCmp { class FooCmp {
@ContentChild('bar', {read: TemplateRef, static: false}) child: any; @ContentChild('bar', {read: TemplateRef}) child: any;
@ContentChildren(TemplateRef) children: any; @ContentChildren(TemplateRef) children: any;
get aview(): any { return null; } get aview(): any { return null; }
@ViewChild('accessor') set aview(value: any) {} @ViewChild('accessor') set aview(value: any) {}
@ -1715,11 +1715,11 @@ runInEachFileSystem(os => {
template: '<div #foo></div>', template: '<div #foo></div>',
}) })
class FooCmp { class FooCmp {
@ContentChild(forwardRef(() => TemplateRef), {static: false}) child: any; @ContentChild(forwardRef(() => TemplateRef)) child: any;
@ContentChild(forwardRef(function() { return ViewContainerRef; }), {static: false}) child2: any; @ContentChild(forwardRef(function() { return ViewContainerRef; })) child2: any;
@ContentChild((forwardRef((function() { return 'parens'; }) as any)), {static: false}) childInParens: any; @ContentChild((forwardRef((function() { return 'parens'; }) as any))) childInParens: any;
} }
`); `);

View File

@ -27,11 +27,10 @@ import * as core from '@angular/core';
typeExtends<compilerCore.Query, core.Query>(); typeExtends<compilerCore.Query, core.Query>();
typeExtends<core.Query, compilerCore.Query>(); typeExtends<core.Query, compilerCore.Query>();
compareRuntimeShape( compareRuntimeShape(
new core.ContentChild('someSelector', {static: false}), new core.ContentChild('someSelector'), compilerCore.createContentChild('someSelector'));
compilerCore.createContentChild('someSelector', {static: false}));
compareRuntimeShape( compareRuntimeShape(
new core.ContentChild('someSelector', {read: 'someRead', static: false}), new core.ContentChild('someSelector', {read: 'someRead'}),
compilerCore.createContentChild('someSelector', {read: 'someRead', static: false})); compilerCore.createContentChild('someSelector', {read: 'someRead'}));
compareRuntimeShape( compareRuntimeShape(
new core.ContentChildren('someSelector'), new core.ContentChildren('someSelector'),
compilerCore.createContentChildren('someSelector')); compilerCore.createContentChildren('someSelector'));
@ -40,11 +39,10 @@ import * as core from '@angular/core';
compilerCore.createContentChildren( compilerCore.createContentChildren(
'someSelector', {read: 'someRead', descendants: false})); 'someSelector', {read: 'someRead', descendants: false}));
compareRuntimeShape( compareRuntimeShape(
new core.ViewChild('someSelector', {static: false}), new core.ViewChild('someSelector'), compilerCore.createViewChild('someSelector'));
compilerCore.createViewChild('someSelector', {static: false}));
compareRuntimeShape( compareRuntimeShape(
new core.ViewChild('someSelector', {read: 'someRead', static: false}), new core.ViewChild('someSelector', {read: 'someRead'}),
compilerCore.createViewChild('someSelector', {read: 'someRead', static: false})); compilerCore.createViewChild('someSelector', {read: 'someRead'}));
compareRuntimeShape( compareRuntimeShape(
new core.ViewChildren('someSelector'), compilerCore.createViewChildren('someSelector')); new core.ViewChildren('someSelector'), compilerCore.createViewChildren('someSelector'));
compareRuntimeShape( compareRuntimeShape(

View File

@ -68,15 +68,15 @@ class SomeDirectiveWithViewChildren {
c: any; c: any;
} }
@Directive({selector: 'someDirective', queries: {'c': new ContentChild('c', {static: false})}}) @Directive({selector: 'someDirective', queries: {'c': new ContentChild('c')}})
class SomeDirectiveWithContentChild { class SomeDirectiveWithContentChild {
@ContentChild('a', {static: false}) a: any; @ContentChild('a') a: any;
c: any; c: any;
} }
@Directive({selector: 'someDirective', queries: {'c': new ViewChild('c', {static: false})}}) @Directive({selector: 'someDirective', queries: {'c': new ViewChild('c')}})
class SomeDirectiveWithViewChild { class SomeDirectiveWithViewChild {
@ViewChild('a', {static: false}) a: any; @ViewChild('a') a: any;
c: any; c: any;
} }
@ -408,41 +408,37 @@ class SomeDirectiveWithoutMetadata {}
it('should append ContentChild', () => { it('should append ContentChild', () => {
const directiveMetadata = resolver.resolve(SomeDirectiveWithContentChild); const directiveMetadata = resolver.resolve(SomeDirectiveWithContentChild);
expect(directiveMetadata.queries).toEqual({ expect(directiveMetadata.queries)
'c': new ContentChild('c', {static: false}), .toEqual({'c': new ContentChild('c'), 'a': new ContentChild('a')});
'a': new ContentChild('a', {static: false})
});
}); });
it('should append ViewChild', () => { it('should append ViewChild', () => {
const directiveMetadata = resolver.resolve(SomeDirectiveWithViewChild); const directiveMetadata = resolver.resolve(SomeDirectiveWithViewChild);
expect(directiveMetadata.queries).toEqual({ expect(directiveMetadata.queries)
'c': new ViewChild('c', {static: false}), .toEqual({'c': new ViewChild('c'), 'a': new ViewChild('a')});
'a': new ViewChild('a', {static: false})
});
}); });
it('should support inheriting queries', () => { it('should support inheriting queries', () => {
@Directive({selector: 'p'}) @Directive({selector: 'p'})
class Parent { class Parent {
@ContentChild('p1', {static: false}) @ContentChild('p1')
p1: any; p1: any;
@ContentChild('p21', {static: false}) @ContentChild('p21')
p2: any; p2: any;
} }
class Child extends Parent { class Child extends Parent {
@ContentChild('p22', {static: false}) @ContentChild('p22')
p2: any; p2: any;
@ContentChild('p3', {static: false}) @ContentChild('p3')
p3: any; p3: any;
} }
const directiveMetadata = resolver.resolve(Child); const directiveMetadata = resolver.resolve(Child);
expect(directiveMetadata.queries).toEqual({ expect(directiveMetadata.queries).toEqual({
'p1': new ContentChild('p1', {static: false}), 'p1': new ContentChild('p1'),
'p2': new ContentChild('p22', {static: false}), 'p2': new ContentChild('p22'),
'p3': new ContentChild('p3', {static: false}) 'p3': new ContentChild('p3')
}); });
}); });
}); });

View File

@ -183,7 +183,7 @@ describe('Google3 undecorated classes with decorated fields TSLint rule', () =>
import { ViewChild, ElementRef } from '@angular/core'; import { ViewChild, ElementRef } from '@angular/core';
export class Base { export class Base {
@ViewChild('button', { static: false }) button: ElementRef<HTMLElement>; @ViewChild('button') button: ElementRef<HTMLElement>;
} }
`); `);
@ -209,7 +209,7 @@ describe('Google3 undecorated classes with decorated fields TSLint rule', () =>
import { ContentChild, ElementRef } from '@angular/core'; import { ContentChild, ElementRef } from '@angular/core';
export class Base { export class Base {
@ContentChild('button', { static: false }) button: ElementRef<HTMLElement>; @ContentChild('button') button: ElementRef<HTMLElement>;
} }
`); `);

View File

@ -159,7 +159,7 @@ describe('Undecorated classes with decorated fields migration', () => {
import { ViewChild, ElementRef } from '@angular/core'; import { ViewChild, ElementRef } from '@angular/core';
export class Base { export class Base {
@ViewChild('button', { static: false }) button: ElementRef<HTMLElement>; @ViewChild('button') button: ElementRef<HTMLElement>;
} }
`); `);
@ -185,7 +185,7 @@ describe('Undecorated classes with decorated fields migration', () => {
import { ContentChild, ElementRef } from '@angular/core'; import { ContentChild, ElementRef } from '@angular/core';
export class Base { export class Base {
@ContentChild('button', { static: false }) button: ElementRef<HTMLElement>; @ContentChild('button') button: ElementRef<HTMLElement>;
} }
`); `);

View File

@ -80,7 +80,7 @@ describe('change detection', () => {
}) })
class TestCmpt { class TestCmpt {
counter = 0; counter = 0;
@ViewChild('vc', {read: ViewContainerRef, static: false}) vcRef !: ViewContainerRef; @ViewChild('vc', {read: ViewContainerRef}) vcRef !: ViewContainerRef;
constructor(private _cfr: ComponentFactoryResolver) {} constructor(private _cfr: ComponentFactoryResolver) {}
@ -146,7 +146,7 @@ describe('change detection', () => {
@Component({selector: 'my-app', template: '<my-comp [name]="name"></my-comp>'}) @Component({selector: 'my-app', template: '<my-comp [name]="name"></my-comp>'})
class MyApp { class MyApp {
@ViewChild(MyComponent, {static: false}) comp !: MyComponent; @ViewChild(MyComponent) comp !: MyComponent;
name: string = 'Nancy'; name: string = 'Nancy';
} }
@ -238,7 +238,7 @@ describe('change detection', () => {
template: '<my-comp></my-comp><button id="parent" (click)="noop()"></button>' template: '<my-comp></my-comp><button id="parent" (click)="noop()"></button>'
}) })
class ButtonParent { class ButtonParent {
@ViewChild(MyComponent, {static: false}) comp !: MyComponent; @ViewChild(MyComponent) comp !: MyComponent;
noop() {} noop() {}
} }
@ -264,7 +264,7 @@ describe('change detection', () => {
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
class ButtonParent implements DoCheck { class ButtonParent implements DoCheck {
@ViewChild(MyComponent, {static: false}) comp !: MyComponent; @ViewChild(MyComponent) comp !: MyComponent;
noop() {} noop() {}
doCheckCount = 0; doCheckCount = 0;
@ -273,7 +273,7 @@ describe('change detection', () => {
@Component({selector: 'my-button-app', template: '<button-parent></button-parent>'}) @Component({selector: 'my-button-app', template: '<button-parent></button-parent>'})
class MyButtonApp { class MyButtonApp {
@ViewChild(ButtonParent, {static: false}) parent !: ButtonParent; @ViewChild(ButtonParent) parent !: ButtonParent;
} }
TestBed.configureTestingModule({declarations: [MyButtonApp, MyComponent, ButtonParent]}); TestBed.configureTestingModule({declarations: [MyButtonApp, MyComponent, ButtonParent]});
@ -326,7 +326,7 @@ describe('change detection', () => {
@Component({selector: 'parent-comp', template: `{{ doCheckCount}} - <my-comp></my-comp>`}) @Component({selector: 'parent-comp', template: `{{ doCheckCount}} - <my-comp></my-comp>`})
class ParentComp implements DoCheck { class ParentComp implements DoCheck {
@ViewChild(MyComp, {static: false}) myComp !: MyComp; @ViewChild(MyComp) myComp !: MyComp;
doCheckCount = 0; doCheckCount = 0;
@ -411,8 +411,8 @@ describe('change detection', () => {
it('should check component view when called by directive on component node', () => { it('should check component view when called by directive on component node', () => {
@Component({template: '<my-comp dir></my-comp>'}) @Component({template: '<my-comp dir></my-comp>'})
class MyApp { class MyApp {
@ViewChild(MyComp, {static: false}) myComp !: MyComp; @ViewChild(MyComp) myComp !: MyComp;
@ViewChild(Dir, {static: false}) dir !: Dir; @ViewChild(Dir) dir !: Dir;
} }
TestBed.configureTestingModule({declarations: [MyComp, Dir, MyApp]}); TestBed.configureTestingModule({declarations: [MyComp, Dir, MyApp]});
@ -429,8 +429,8 @@ describe('change detection', () => {
it('should check host component when called by directive on element node', () => { it('should check host component when called by directive on element node', () => {
@Component({template: '{{ value }}<div dir></div>'}) @Component({template: '{{ value }}<div dir></div>'})
class MyApp { class MyApp {
@ViewChild(MyComp, {static: false}) myComp !: MyComp; @ViewChild(MyComp) myComp !: MyComp;
@ViewChild(Dir, {static: false}) dir !: Dir; @ViewChild(Dir) dir !: Dir;
value = ''; value = '';
} }
@ -450,7 +450,7 @@ describe('change detection', () => {
it('should check the host component when called from EmbeddedViewRef', () => { it('should check the host component when called from EmbeddedViewRef', () => {
@Component({template: '{{ name }}<div *ngIf="showing" dir></div>'}) @Component({template: '{{ name }}<div *ngIf="showing" dir></div>'})
class MyApp { class MyApp {
@ViewChild(Dir, {static: false}) dir !: Dir; @ViewChild(Dir) dir !: Dir;
showing = true; showing = true;
name = 'Amelia'; name = 'Amelia';
} }
@ -601,7 +601,7 @@ describe('change detection', () => {
'<ng-template #foo let-ctx="ctx">{{ ctx.value }}</ng-template><structural-comp [tmp]="foo"></structural-comp>' '<ng-template #foo let-ctx="ctx">{{ ctx.value }}</ng-template><structural-comp [tmp]="foo"></structural-comp>'
}) })
class App { class App {
@ViewChild(StructuralComp, {static: false}) structuralComp !: StructuralComp; @ViewChild(StructuralComp) structuralComp !: StructuralComp;
} }
TestBed.configureTestingModule({declarations: [App, StructuralComp]}); TestBed.configureTestingModule({declarations: [App, StructuralComp]});
@ -630,7 +630,7 @@ describe('change detection', () => {
template: '<ng-template #foo>Template text</ng-template><structural-comp [tmp]="foo">' template: '<ng-template #foo>Template text</ng-template><structural-comp [tmp]="foo">'
}) })
class App { class App {
@ViewChild(StructuralComp, {static: false}) structuralComp !: StructuralComp; @ViewChild(StructuralComp) structuralComp !: StructuralComp;
} }
TestBed.configureTestingModule({declarations: [App, StructuralComp]}); TestBed.configureTestingModule({declarations: [App, StructuralComp]});
@ -661,7 +661,7 @@ describe('change detection', () => {
@Component({template: '<detached-comp></detached-comp>'}) @Component({template: '<detached-comp></detached-comp>'})
class MyApp { class MyApp {
@ViewChild(DetachedComp, {static: false}) comp !: DetachedComp; @ViewChild(DetachedComp) comp !: DetachedComp;
constructor(public cdr: ChangeDetectorRef) {} constructor(public cdr: ChangeDetectorRef) {}
} }
@ -772,7 +772,7 @@ describe('change detection', () => {
@Component({template: '<on-push-comp [value]="value"></on-push-comp>'}) @Component({template: '<on-push-comp [value]="value"></on-push-comp>'})
class OnPushApp { class OnPushApp {
@ViewChild(OnPushComp, {static: false}) onPushComp !: OnPushComp; @ViewChild(OnPushComp) onPushComp !: OnPushComp;
value = ''; value = '';
} }
@ -819,7 +819,7 @@ describe('change detection', () => {
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
class OnPushParent { class OnPushParent {
@ViewChild(OnPushComp, {static: false}) comp !: OnPushComp; @ViewChild(OnPushComp) comp !: OnPushComp;
value = 'one'; value = 'one';
} }
@ -881,7 +881,7 @@ describe('change detection', () => {
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
class EmbeddedViewParent { class EmbeddedViewParent {
@ViewChild(OnPushComp, {static: false}) comp !: OnPushComp; @ViewChild(OnPushComp) comp !: OnPushComp;
value = 'one'; value = 'one';
showing = true; showing = true;
} }

View File

@ -239,7 +239,7 @@ describe('component', () => {
encapsulation: ViewEncapsulation.Emulated, encapsulation: ViewEncapsulation.Emulated,
}) })
class Parent { class Parent {
@ViewChild(Child, {static: false}) childInstance !: Child; @ViewChild(Child) childInstance !: Child;
constructor(public renderer: Renderer2) {} constructor(public renderer: Renderer2) {}
} }

View File

@ -405,7 +405,7 @@ describe('di', () => {
</div>` </div>`
}) })
class MyComp { class MyComp {
@ViewChild(StructuralDirective, {static: false}) structuralDir !: StructuralDirective; @ViewChild(StructuralDirective) structuralDir !: StructuralDirective;
} }
TestBed.configureTestingModule( TestBed.configureTestingModule(
@ -449,8 +449,8 @@ describe('di', () => {
</div>` </div>`
}) })
class MyApp { class MyApp {
@ViewChild(HostBindingDirective, {static: false}) hostBindingDir !: HostBindingDirective; @ViewChild(HostBindingDirective) hostBindingDir !: HostBindingDirective;
@ViewChild(DirectiveA, {static: false}) dirA !: DirectiveA; @ViewChild(DirectiveA) dirA !: DirectiveA;
} }
TestBed.configureTestingModule( TestBed.configureTestingModule(
@ -563,7 +563,7 @@ describe('di', () => {
@Component({template: '<div dirA></div>'}) @Component({template: '<div dirA></div>'})
class MyComp { class MyComp {
@ViewChild(DirectiveA, {static: false}) dirA !: DirectiveA; @ViewChild(DirectiveA) dirA !: DirectiveA;
} }
TestBed.configureTestingModule({declarations: [DirectiveA, DirectiveB, MyComp]}); TestBed.configureTestingModule({declarations: [DirectiveA, DirectiveB, MyComp]});
@ -583,7 +583,7 @@ describe('di', () => {
@Component({template: '<div dirC></div>'}) @Component({template: '<div dirC></div>'})
class MyComp { class MyComp {
@ViewChild(DirectiveC, {static: false}) dirC !: DirectiveC; @ViewChild(DirectiveC) dirC !: DirectiveC;
} }
TestBed.configureTestingModule({declarations: [DirectiveC, MyComp]}); TestBed.configureTestingModule({declarations: [DirectiveC, MyComp]});
@ -603,7 +603,7 @@ describe('di', () => {
@Component({template: '<div dirB></div><div dirC></div>'}) @Component({template: '<div dirB></div><div dirC></div>'})
class MyComp { class MyComp {
@ViewChild(DirectiveC, {static: false}) dirC !: DirectiveC; @ViewChild(DirectiveC) dirC !: DirectiveC;
} }
TestBed.configureTestingModule({declarations: [DirectiveB, DirectiveC, MyComp]}); TestBed.configureTestingModule({declarations: [DirectiveB, DirectiveC, MyComp]});
@ -624,12 +624,12 @@ describe('di', () => {
@Component({selector: 'my-comp', template: '<div dirA dirB="self"></div>'}) @Component({selector: 'my-comp', template: '<div dirA dirB="self"></div>'})
class MyComp { class MyComp {
@ViewChild(DirectiveA, {static: false}) dirA !: DirectiveA; @ViewChild(DirectiveA) dirA !: DirectiveA;
} }
@Component({template: '<my-comp dirB="parent"></my-comp>'}) @Component({template: '<my-comp dirB="parent"></my-comp>'})
class MyApp { class MyApp {
@ViewChild(MyComp, {static: false}) myComp !: MyComp; @ViewChild(MyComp) myComp !: MyComp;
} }
TestBed.configureTestingModule({declarations: [DirectiveA, DirectiveB, MyComp, MyApp]}); TestBed.configureTestingModule({declarations: [DirectiveA, DirectiveB, MyComp, MyApp]});
@ -674,12 +674,12 @@ describe('di', () => {
viewProviders: [{provide: String, useValue: 'Foo'}] viewProviders: [{provide: String, useValue: 'Foo'}]
}) })
class MyComp { class MyComp {
@ViewChild(DirectiveString, {static: false}) dirString !: DirectiveString; @ViewChild(DirectiveString) dirString !: DirectiveString;
} }
@Component({template: '<my-comp></my-comp>'}) @Component({template: '<my-comp></my-comp>'})
class MyApp { class MyApp {
@ViewChild(MyComp, {static: false}) myComp !: MyComp; @ViewChild(MyComp) myComp !: MyComp;
} }
TestBed.configureTestingModule({declarations: [DirectiveString, MyComp, MyApp]}); TestBed.configureTestingModule({declarations: [DirectiveString, MyComp, MyApp]});
@ -698,12 +698,12 @@ describe('di', () => {
@Component({selector: 'my-comp', template: '<div dirComp></div>'}) @Component({selector: 'my-comp', template: '<div dirComp></div>'})
class MyComp { class MyComp {
@ViewChild(DirectiveComp, {static: false}) dirComp !: DirectiveComp; @ViewChild(DirectiveComp) dirComp !: DirectiveComp;
} }
@Component({template: '<my-comp></my-comp>'}) @Component({template: '<my-comp></my-comp>'})
class MyApp { class MyApp {
@ViewChild(MyComp, {static: false}) myComp !: MyComp; @ViewChild(MyComp) myComp !: MyComp;
} }
TestBed.configureTestingModule({declarations: [DirectiveComp, MyComp, MyApp]}); TestBed.configureTestingModule({declarations: [DirectiveComp, MyComp, MyApp]});
@ -762,7 +762,7 @@ describe('di', () => {
@Component({template: '<my-comp dirB></my-comp>'}) @Component({template: '<my-comp dirB></my-comp>'})
class MyApp { class MyApp {
@ViewChild(MyComp, {static: false}) myComp !: MyComp; @ViewChild(MyComp) myComp !: MyComp;
} }
TestBed.configureTestingModule( TestBed.configureTestingModule(
@ -779,8 +779,8 @@ describe('di', () => {
@Component({template: '<div dirB><div *ngIf="showing" dirA></div></div>'}) @Component({template: '<div dirB><div *ngIf="showing" dirA></div></div>'})
class MyApp { class MyApp {
showing = false; showing = false;
@ViewChild(DirectiveA, {static: false}) dirA !: DirectiveA; @ViewChild(DirectiveA) dirA !: DirectiveA;
@ViewChild(DirectiveB, {static: false}) dirB !: DirectiveB; @ViewChild(DirectiveB) dirB !: DirectiveB;
} }
TestBed.configureTestingModule({declarations: [DirectiveA, DirectiveB, MyApp]}); TestBed.configureTestingModule({declarations: [DirectiveA, DirectiveB, MyApp]});
@ -1042,8 +1042,8 @@ describe('di', () => {
@Component({template: '<div injectorDir otherInjectorDir></div>'}) @Component({template: '<div injectorDir otherInjectorDir></div>'})
class MyComp { class MyComp {
@ViewChild(InjectorDir, {static: false}) injectorDir !: InjectorDir; @ViewChild(InjectorDir) injectorDir !: InjectorDir;
@ViewChild(OtherInjectorDir, {static: false}) otherInjectorDir !: OtherInjectorDir; @ViewChild(OtherInjectorDir) otherInjectorDir !: OtherInjectorDir;
} }
TestBed.configureTestingModule({declarations: [InjectorDir, OtherInjectorDir, MyComp]}); TestBed.configureTestingModule({declarations: [InjectorDir, OtherInjectorDir, MyComp]});
@ -1068,7 +1068,7 @@ describe('di', () => {
@Component({template: '<div injectorDir></div>'}) @Component({template: '<div injectorDir></div>'})
class MyComp { class MyComp {
@ViewChild(InjectorDir, {static: false}) injectorDir !: InjectorDir; @ViewChild(InjectorDir) injectorDir !: InjectorDir;
} }
TestBed.configureTestingModule({declarations: [InjectorDir, MyComp]}); TestBed.configureTestingModule({declarations: [InjectorDir, MyComp]});
@ -1105,8 +1105,8 @@ describe('di', () => {
@Component({template: '<div dir otherDir></div>'}) @Component({template: '<div dir otherDir></div>'})
class MyComp { class MyComp {
@ViewChild(MyDir, {static: false}) directive !: MyDir; @ViewChild(MyDir) directive !: MyDir;
@ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir; @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
} }
TestBed.configureTestingModule({declarations: [MyDir, MyOtherDir, MyComp]}); TestBed.configureTestingModule({declarations: [MyDir, MyOtherDir, MyComp]});
@ -1137,7 +1137,7 @@ describe('di', () => {
@Component({template: '<ng-template dir></ng-template>'}) @Component({template: '<ng-template dir></ng-template>'})
class MyComp { class MyComp {
@ViewChild(MyDir, {static: false}) directive !: MyDir; @ViewChild(MyDir) directive !: MyDir;
} }
TestBed.configureTestingModule({declarations: [MyDir, MyComp]}); TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@ -1172,7 +1172,7 @@ describe('di', () => {
template: `<div id="test-id" dir></div>`, template: `<div id="test-id" dir></div>`,
}) })
class ChildComp { class ChildComp {
@ViewChild(DirectiveA, {static: false}) directive !: DirectiveA; @ViewChild(DirectiveA) directive !: DirectiveA;
} }
@Component({ @Component({
@ -1238,8 +1238,8 @@ describe('di', () => {
template: '<ng-template dir otherDir #dir="dir" #otherDir="otherDir"></ng-template>' template: '<ng-template dir otherDir #dir="dir" #otherDir="otherDir"></ng-template>'
}) })
class MyComp { class MyComp {
@ViewChild(MyDir, {static: false}) directive !: MyDir; @ViewChild(MyDir) directive !: MyDir;
@ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir; @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
} }
TestBed.configureTestingModule({declarations: [MyDir, MyOtherDir, MyComp]}); TestBed.configureTestingModule({declarations: [MyDir, MyOtherDir, MyComp]});
@ -1282,7 +1282,7 @@ describe('di', () => {
} }
@Component({template: '<div optionalDir></div>'}) @Component({template: '<div optionalDir></div>'})
class MyComp { class MyComp {
@ViewChild(OptionalDir, {static: false}) directive !: OptionalDir; @ViewChild(OptionalDir) directive !: OptionalDir;
} }
TestBed.configureTestingModule({declarations: [OptionalDir, MyComp]}); TestBed.configureTestingModule({declarations: [OptionalDir, MyComp]});
@ -1311,8 +1311,8 @@ describe('di', () => {
} }
@Component({template: '<div dir otherDir #dir="dir" #otherDir="otherDir"></div>'}) @Component({template: '<div dir otherDir #dir="dir" #otherDir="otherDir"></div>'})
class MyComp { class MyComp {
@ViewChild(MyDir, {static: false}) directive !: MyDir; @ViewChild(MyDir) directive !: MyDir;
@ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir; @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
} }
TestBed.configureTestingModule({declarations: [MyDir, MyOtherDir, MyComp]}); TestBed.configureTestingModule({declarations: [MyDir, MyOtherDir, MyComp]});
@ -1408,9 +1408,9 @@ describe('di', () => {
() => { () => {
@Component({selector: 'my-app', template: '<my-comp dir otherDir #dir="dir"></my-comp>'}) @Component({selector: 'my-app', template: '<my-comp dir otherDir #dir="dir"></my-comp>'})
class MyApp { class MyApp {
@ViewChild(MyComp, {static: false}) component !: MyComp; @ViewChild(MyComp) component !: MyComp;
@ViewChild(MyDir, {static: false}) directive !: MyDir; @ViewChild(MyDir) directive !: MyDir;
@ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir; @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
} }
TestBed.configureTestingModule({declarations: [MyApp, MyComp, MyDir, MyOtherDir]}); TestBed.configureTestingModule({declarations: [MyApp, MyComp, MyDir, MyOtherDir]});
const fixture = TestBed.createComponent(MyApp); const fixture = TestBed.createComponent(MyApp);
@ -1431,8 +1431,8 @@ describe('di', () => {
@Component({selector: 'my-comp', template: '<div dir otherDir #dir="dir"></div>'}) @Component({selector: 'my-comp', template: '<div dir otherDir #dir="dir"></div>'})
class MyComp { class MyComp {
constructor(public cdr: ChangeDetectorRef) {} constructor(public cdr: ChangeDetectorRef) {}
@ViewChild(MyDir, {static: false}) directive !: MyDir; @ViewChild(MyDir) directive !: MyDir;
@ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir; @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
} }
TestBed.configureTestingModule({declarations: [MyComp, MyDir, MyOtherDir]}); TestBed.configureTestingModule({declarations: [MyComp, MyDir, MyOtherDir]});
const fixture = TestBed.createComponent(MyComp); const fixture = TestBed.createComponent(MyComp);
@ -1458,9 +1458,9 @@ describe('di', () => {
}) })
class MyApp { class MyApp {
constructor(public cdr: ChangeDetectorRef) {} constructor(public cdr: ChangeDetectorRef) {}
@ViewChild(MyComp, {static: false}) component !: MyComp; @ViewChild(MyComp) component !: MyComp;
@ViewChild(MyDir, {static: false}) directive !: MyDir; @ViewChild(MyDir) directive !: MyDir;
@ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir; @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
} }
TestBed.configureTestingModule({declarations: [MyApp, MyComp, MyDir, MyOtherDir]}); TestBed.configureTestingModule({declarations: [MyApp, MyComp, MyDir, MyOtherDir]});
const fixture = TestBed.createComponent(MyApp); const fixture = TestBed.createComponent(MyApp);
@ -1486,8 +1486,8 @@ describe('di', () => {
class MyComp { class MyComp {
showing = true; showing = true;
constructor(public cdr: ChangeDetectorRef) {} constructor(public cdr: ChangeDetectorRef) {}
@ViewChild(MyDir, {static: false}) directive !: MyDir; @ViewChild(MyDir) directive !: MyDir;
@ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir; @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
} }
TestBed.configureTestingModule({declarations: [MyComp, MyDir, MyOtherDir]}); TestBed.configureTestingModule({declarations: [MyComp, MyDir, MyOtherDir]});
@ -1509,8 +1509,8 @@ describe('di', () => {
class MyComp { class MyComp {
showing = true; showing = true;
constructor(public cdr: ChangeDetectorRef) {} constructor(public cdr: ChangeDetectorRef) {}
@ViewChild(MyDir, {static: false}) directive !: MyDir; @ViewChild(MyDir) directive !: MyDir;
@ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir; @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
} }
TestBed.configureTestingModule({declarations: [MyComp, MyDir, MyOtherDir]}); TestBed.configureTestingModule({declarations: [MyComp, MyDir, MyOtherDir]});
@ -1559,7 +1559,7 @@ describe('di', () => {
@Component({template: '<div injectorDir></div>'}) @Component({template: '<div injectorDir></div>'})
class MyComp { class MyComp {
@ViewChild(InjectorDir, {static: false}) injectorDirInstance !: InjectorDir; @ViewChild(InjectorDir) injectorDirInstance !: InjectorDir;
} }
TestBed.configureTestingModule({declarations: [InjectorDir, MyComp]}); TestBed.configureTestingModule({declarations: [InjectorDir, MyComp]});
@ -1652,7 +1652,7 @@ describe('di', () => {
providers: [{provide: LOCALE_ID, useValue: 'en-GB'}] providers: [{provide: LOCALE_ID, useValue: 'en-GB'}]
}) })
class MyComp { class MyComp {
@ViewChild(MyDir, {static: false}) myDir !: MyDir; @ViewChild(MyDir) myDir !: MyDir;
constructor(@Inject(LOCALE_ID) public localeId: string) {} constructor(@Inject(LOCALE_ID) public localeId: string) {}
} }
@ -1674,7 +1674,7 @@ describe('di', () => {
@Component({template: '<div dir exist="existValue" other="ignore"></div>'}) @Component({template: '<div dir exist="existValue" other="ignore"></div>'})
class MyComp { class MyComp {
@ViewChild(MyDir, {static: false}) directiveInstance !: MyDir; @ViewChild(MyDir) directiveInstance !: MyDir;
} }
TestBed.configureTestingModule({declarations: [MyDir, MyComp]}); TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@ -1698,7 +1698,7 @@ describe('di', () => {
@Component( @Component(
{template: '<ng-template dir="initial" exist="existValue" other="ignore"></ng-template>'}) {template: '<ng-template dir="initial" exist="existValue" other="ignore"></ng-template>'})
class MyComp { class MyComp {
@ViewChild(MyDir, {static: false}) directiveInstance !: MyDir; @ViewChild(MyDir) directiveInstance !: MyDir;
} }
TestBed.configureTestingModule({declarations: [MyDir, MyComp]}); TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@ -1723,7 +1723,7 @@ describe('di', () => {
template: '<ng-container dir="initial" exist="existValue" other="ignore"></ng-container>' template: '<ng-container dir="initial" exist="existValue" other="ignore"></ng-container>'
}) })
class MyComp { class MyComp {
@ViewChild(MyDir, {static: false}) directiveInstance !: MyDir; @ViewChild(MyDir) directiveInstance !: MyDir;
} }
TestBed.configureTestingModule({declarations: [MyDir, MyComp]}); TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@ -1750,7 +1750,7 @@ describe('di', () => {
'<div dir style="margin: 1px; color: red;" class="hello there" other-attr="value"></div>' '<div dir style="margin: 1px; color: red;" class="hello there" other-attr="value"></div>'
}) })
class MyComp { class MyComp {
@ViewChild(MyDir, {static: false}) directiveInstance !: MyDir; @ViewChild(MyDir) directiveInstance !: MyDir;
} }
TestBed.configureTestingModule({declarations: [MyDir, MyComp]}); TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@ -1778,7 +1778,7 @@ describe('di', () => {
template: '<div dir exist="existValue" svg:exist="testExistValue" other="otherValue"></div>' template: '<div dir exist="existValue" svg:exist="testExistValue" other="otherValue"></div>'
}) })
class MyComp { class MyComp {
@ViewChild(MyDir, {static: false}) directiveInstance !: MyDir; @ViewChild(MyDir) directiveInstance !: MyDir;
} }
TestBed.configureTestingModule({declarations: [MyDir, MyComp]}); TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@ -1809,7 +1809,7 @@ describe('di', () => {
'<div dir exist="existValue" [binding]="bindingValue" (output)="outputValue" other="otherValue" ignore="ignoreValue"></div>' '<div dir exist="existValue" [binding]="bindingValue" (output)="outputValue" other="otherValue" ignore="ignoreValue"></div>'
}) })
class MyComp { class MyComp {
@ViewChild(MyDir, {static: false}) directiveInstance !: MyDir; @ViewChild(MyDir) directiveInstance !: MyDir;
} }
TestBed.configureTestingModule({declarations: [MyDir, MyComp]}); TestBed.configureTestingModule({declarations: [MyDir, MyComp]});

View File

@ -312,9 +312,9 @@ onlyInIvy('Ivy-specific utilities').describe('discovery utils deprecated', () =>
` `
}) })
class Comp { class Comp {
@ViewChild(MyDir1, {static: false}) myDir1Instance !: MyDir1; @ViewChild(MyDir1) myDir1Instance !: MyDir1;
@ViewChild(MyDir2, {static: false}) myDir2Instance !: MyDir2; @ViewChild(MyDir2) myDir2Instance !: MyDir2;
@ViewChild(MyDir3, {static: false}) myDir3Instance !: MyDir3; @ViewChild(MyDir3) myDir3Instance !: MyDir3;
} }
TestBed.configureTestingModule({declarations: [Comp, MyDir1, MyDir2, MyDir3]}); TestBed.configureTestingModule({declarations: [Comp, MyDir1, MyDir2, MyDir3]});

View File

@ -121,7 +121,7 @@ describe('host bindings', () => {
class ParentCmp { class ParentCmp {
private _prop = ''; private _prop = '';
@ViewChild('template', {read: ViewContainerRef, static: false}) @ViewChild('template', {read: ViewContainerRef})
vcr: ViewContainerRef = null !; vcr: ViewContainerRef = null !;
private child: ComponentRef<ChildCmp> = null !; private child: ComponentRef<ChildCmp> = null !;
@ -314,7 +314,7 @@ describe('host bindings', () => {
@Component({template: '<span dir></span>'}) @Component({template: '<span dir></span>'})
class App { class App {
@ViewChild(Dir, {static: false}) directiveInstance !: Dir; @ViewChild(Dir) directiveInstance !: Dir;
} }
TestBed.configureTestingModule({declarations: [App, Dir]}); TestBed.configureTestingModule({declarations: [App, Dir]});
@ -403,7 +403,7 @@ describe('host bindings', () => {
` `
}) })
class App { class App {
@ViewChild(HostBindingDir, {static: false}) hostBindingDir !: HostBindingDir; @ViewChild(HostBindingDir) hostBindingDir !: HostBindingDir;
} }
TestBed.configureTestingModule({declarations: [App, SomeDir, HostTitleComp, HostBindingDir]}); TestBed.configureTestingModule({declarations: [App, SomeDir, HostTitleComp, HostBindingDir]});
@ -471,7 +471,7 @@ describe('host bindings', () => {
@Component({template: '<div someDir hostBindingDir></div>'}) @Component({template: '<div someDir hostBindingDir></div>'})
class App { class App {
@ViewChild(HostBindingDir, {static: false}) hostBindingDir !: HostBindingDir; @ViewChild(HostBindingDir) hostBindingDir !: HostBindingDir;
} }
TestBed.configureTestingModule({declarations: [App, SomeDir, HostBindingDir]}); TestBed.configureTestingModule({declarations: [App, SomeDir, HostBindingDir]});
@ -539,7 +539,7 @@ describe('host bindings', () => {
@Component({template: '<input hostBindingDir [disabled]="isDisabled">'}) @Component({template: '<input hostBindingDir [disabled]="isDisabled">'})
class App { class App {
@ViewChild(HostBindingInputDir, {static: false}) hostBindingInputDir !: HostBindingInputDir; @ViewChild(HostBindingInputDir) hostBindingInputDir !: HostBindingInputDir;
isDisabled = true; isDisabled = true;
} }
@ -629,7 +629,7 @@ describe('host bindings', () => {
` `
}) })
class App { class App {
@ViewChild(NameComp, {static: false}) nameComp !: NameComp; @ViewChild(NameComp) nameComp !: NameComp;
name = ''; name = '';
} }
@ -685,8 +685,8 @@ describe('host bindings', () => {
` `
}) })
class App { class App {
@ViewChild(HostBindingComp, {static: false}) hostBindingComp !: HostBindingComp; @ViewChild(HostBindingComp) hostBindingComp !: HostBindingComp;
@ViewChild(NameComp, {static: false}) nameComp !: NameComp; @ViewChild(NameComp) nameComp !: NameComp;
name = ''; name = '';
otherName = ''; otherName = '';
} }
@ -760,8 +760,8 @@ describe('host bindings', () => {
@Component({template: '<host-binding-comp hostDir></host-binding-comp>'}) @Component({template: '<host-binding-comp hostDir></host-binding-comp>'})
class App { class App {
@ViewChild(HostBindingComp, {static: false}) hostBindingComp !: HostBindingComp; @ViewChild(HostBindingComp) hostBindingComp !: HostBindingComp;
@ViewChild(HostBindingDir, {static: false}) hostBindingDir !: HostBindingDir; @ViewChild(HostBindingDir) hostBindingDir !: HostBindingDir;
} }
TestBed.configureTestingModule({declarations: [App, HostBindingComp, HostBindingDir]}); TestBed.configureTestingModule({declarations: [App, HostBindingComp, HostBindingDir]});
@ -799,7 +799,7 @@ describe('host bindings', () => {
@Component({template: `<host-binding-comp></host-binding-comp>{{ name }}`}) @Component({template: `<host-binding-comp></host-binding-comp>{{ name }}`})
class App { class App {
@ViewChild(HostBindingComp, {static: false}) hostBindingComp !: HostBindingComp; @ViewChild(HostBindingComp) hostBindingComp !: HostBindingComp;
name = ''; name = '';
} }
@ -849,8 +849,8 @@ describe('host bindings', () => {
` `
}) })
class App { class App {
@ViewChild(SubDirective, {static: false}) subDir !: SubDirective; @ViewChild(SubDirective) subDir !: SubDirective;
@ViewChild(SuperDirective, {static: false}) superDir !: SuperDirective; @ViewChild(SuperDirective) superDir !: SuperDirective;
} }
TestBed.configureTestingModule({declarations: [App, SuperDirective, SubDirective]}); TestBed.configureTestingModule({declarations: [App, SuperDirective, SubDirective]});
@ -958,7 +958,7 @@ describe('host bindings', () => {
@Component({template: '<host-binding-to-styles></host-binding-to-styles>'}) @Component({template: '<host-binding-to-styles></host-binding-to-styles>'})
class App { class App {
@ViewChild(HostBindingToStyles, {static: false}) hostBindingDir !: HostBindingToStyles; @ViewChild(HostBindingToStyles) hostBindingDir !: HostBindingToStyles;
} }
TestBed.configureTestingModule({declarations: [App, HostBindingToStyles]}); TestBed.configureTestingModule({declarations: [App, HostBindingToStyles]});
@ -987,7 +987,7 @@ describe('host bindings', () => {
@Component({template: '<div hostStyles containerDir></div>'}) @Component({template: '<div hostStyles containerDir></div>'})
class App { class App {
@ViewChild(HostBindingToStyles, {static: false}) hostBindingDir !: HostBindingToStyles; @ViewChild(HostBindingToStyles) hostBindingDir !: HostBindingToStyles;
} }
TestBed.configureTestingModule({declarations: [App, HostBindingToStyles, ContainerDir]}); TestBed.configureTestingModule({declarations: [App, HostBindingToStyles, ContainerDir]});
@ -1038,7 +1038,7 @@ describe('host bindings', () => {
@Component({template: `<${tag} unsafeUrlHostBindingDir></${tag}>`}) @Component({template: `<${tag} unsafeUrlHostBindingDir></${tag}>`})
class App { class App {
@ViewChild(UnsafeDir, {static: false}) unsafeDir !: UnsafeDir; @ViewChild(UnsafeDir) unsafeDir !: UnsafeDir;
} }
TestBed.configureTestingModule({declarations: [App, UnsafeDir]}); TestBed.configureTestingModule({declarations: [App, UnsafeDir]});

View File

@ -243,7 +243,7 @@ describe('acceptance integration tests', () => {
@Component({template: '<div><ng-container dir></ng-container></div>'}) @Component({template: '<div><ng-container dir></ng-container></div>'})
class App { class App {
@ViewChild(TestDirective, {static: false}) testDirective !: TestDirective; @ViewChild(TestDirective) testDirective !: TestDirective;
} }
TestBed.configureTestingModule({declarations: [App, TestDirective]}); TestBed.configureTestingModule({declarations: [App, TestDirective]});
@ -273,7 +273,7 @@ describe('acceptance integration tests', () => {
'<ng-container dir [contentTpl]="content"><ng-template #content>Content</ng-template></ng-container>' '<ng-container dir [contentTpl]="content"><ng-template #content>Content</ng-template></ng-container>'
}) })
class App { class App {
@ViewChild(TestDirective, {static: false}) testDirective !: TestDirective; @ViewChild(TestDirective) testDirective !: TestDirective;
} }
TestBed.configureTestingModule({declarations: [App, TestDirective]}); TestBed.configureTestingModule({declarations: [App, TestDirective]});
@ -303,7 +303,7 @@ describe('acceptance integration tests', () => {
@Component({template: '<ng-container><ng-template dir>Content</ng-template></ng-container>'}) @Component({template: '<ng-container><ng-template dir>Content</ng-template></ng-container>'})
class App { class App {
@ViewChild(TestDirective, {static: false}) testDirective !: TestDirective; @ViewChild(TestDirective) testDirective !: TestDirective;
} }
TestBed.configureTestingModule({declarations: [App, TestDirective]}); TestBed.configureTestingModule({declarations: [App, TestDirective]});
@ -608,7 +608,7 @@ describe('acceptance integration tests', () => {
@Component({template: '<todo></todo>'}) @Component({template: '<todo></todo>'})
class App { class App {
@ViewChild(TodoComponentHostBinding, {static: false}) @ViewChild(TodoComponentHostBinding)
todoComponentHostBinding !: TodoComponentHostBinding; todoComponentHostBinding !: TodoComponentHostBinding;
} }
@ -844,7 +844,7 @@ describe('acceptance integration tests', () => {
@Component({template: '<div hostBindingDir></div>'}) @Component({template: '<div hostBindingDir></div>'})
class App { class App {
@ViewChild(HostBindingDir, {static: false}) hostBindingDir !: HostBindingDir; @ViewChild(HostBindingDir) hostBindingDir !: HostBindingDir;
} }
TestBed.configureTestingModule({declarations: [App, HostBindingDir]}); TestBed.configureTestingModule({declarations: [App, HostBindingDir]});
@ -1012,7 +1012,7 @@ describe('acceptance integration tests', () => {
` `
}) })
class App { class App {
@ViewChild(StructuralComp, {static: false}) structuralComp !: StructuralComp; @ViewChild(StructuralComp) structuralComp !: StructuralComp;
value: any; value: any;
} }
@ -1053,7 +1053,7 @@ describe('acceptance integration tests', () => {
() => { () => {
@Component({template: '<div class="apple orange banana" DirWithClass></div>'}) @Component({template: '<div class="apple orange banana" DirWithClass></div>'})
class App { class App {
@ViewChild(DirWithClassDirective, {static: false}) @ViewChild(DirWithClassDirective)
mockClassDirective !: DirWithClassDirective; mockClassDirective !: DirWithClassDirective;
} }
@ -1071,7 +1071,7 @@ describe('acceptance integration tests', () => {
() => { () => {
@Component({template: '<div style="width:100px;height:200px" DirWithStyle></div>'}) @Component({template: '<div style="width:100px;height:200px" DirWithStyle></div>'})
class App { class App {
@ViewChild(DirWithStyleDirective, {static: false}) @ViewChild(DirWithStyleDirective)
mockStyleDirective !: DirWithStyleDirective; mockStyleDirective !: DirWithStyleDirective;
} }
@ -1090,7 +1090,7 @@ describe('acceptance integration tests', () => {
() => { () => {
@Component({template: '<div DirWithClass [class]="value"></div>'}) @Component({template: '<div DirWithClass [class]="value"></div>'})
class App { class App {
@ViewChild(DirWithClassDirective, {static: false}) @ViewChild(DirWithClassDirective)
mockClassDirective !: DirWithClassDirective; mockClassDirective !: DirWithClassDirective;
value = ''; value = '';
} }
@ -1109,7 +1109,7 @@ describe('acceptance integration tests', () => {
() => { () => {
@Component({template: '<div DirWithStyle [style]="value"></div>'}) @Component({template: '<div DirWithStyle [style]="value"></div>'})
class App { class App {
@ViewChild(DirWithStyleDirective, {static: false}) @ViewChild(DirWithStyleDirective)
mockStyleDirective !: DirWithStyleDirective; mockStyleDirective !: DirWithStyleDirective;
value !: {[key: string]: string}; value !: {[key: string]: string};
} }
@ -1186,7 +1186,7 @@ describe('acceptance integration tests', () => {
` `
}) })
class App { class App {
@ViewChild(DirWithSingleStylingBindings, {static: false}) @ViewChild(DirWithSingleStylingBindings)
dirInstance !: DirWithSingleStylingBindings; dirInstance !: DirWithSingleStylingBindings;
} }
@ -1242,8 +1242,8 @@ describe('acceptance integration tests', () => {
@Component( @Component(
{template: '<div Dir1WithStyle Dir2WithStyle [style.width]="width"></div>'}) {template: '<div Dir1WithStyle Dir2WithStyle [style.width]="width"></div>'})
class App { class App {
@ViewChild(Dir1WithStyle, {static: false}) dir1Instance !: Dir1WithStyle; @ViewChild(Dir1WithStyle) dir1Instance !: Dir1WithStyle;
@ViewChild(Dir2WithStyle, {static: false}) dir2Instance !: Dir2WithStyle; @ViewChild(Dir2WithStyle) dir2Instance !: Dir2WithStyle;
width: string|null = null; width: string|null = null;
} }
@ -1307,8 +1307,8 @@ describe('acceptance integration tests', () => {
'<div Dir1WithStyling Dir2WithStyling [style]="stylesExp" [class]="classesExp"></div>' '<div Dir1WithStyling Dir2WithStyling [style]="stylesExp" [class]="classesExp"></div>'
}) })
class App { class App {
@ViewChild(Dir1WithStyling, {static: false}) dir1Instance !: Dir1WithStyling; @ViewChild(Dir1WithStyling) dir1Instance !: Dir1WithStyling;
@ViewChild(Dir2WithStyling, {static: false}) dir2Instance !: Dir2WithStyling; @ViewChild(Dir2WithStyling) dir2Instance !: Dir2WithStyling;
stylesExp: any = {}; stylesExp: any = {};
classesExp: any = {}; classesExp: any = {};
} }

View File

@ -1293,7 +1293,7 @@ describe('onInit', () => {
`, `,
}) })
class App { class App {
@ViewChild('container', {read: ViewContainerRef, static: false}) @ViewChild('container', {read: ViewContainerRef})
viewContainerRef !: ViewContainerRef; viewContainerRef !: ViewContainerRef;
constructor(public compFactoryResolver: ComponentFactoryResolver) {} constructor(public compFactoryResolver: ComponentFactoryResolver) {}

View File

@ -220,7 +220,7 @@ describe('event listeners', () => {
count = 0; count = 0;
someValue = -1; someValue = -1;
@ViewChild(FooDirective, {static: false}) fooDirective: FooDirective|null = null; @ViewChild(FooDirective) fooDirective: FooDirective|null = null;
fooChange() { this.count++; } fooChange() { this.count++; }

View File

@ -43,7 +43,7 @@ describe('outputs', () => {
@Component({template: '<button-toggle (change)="onChange()"></button-toggle>'}) @Component({template: '<button-toggle (change)="onChange()"></button-toggle>'})
class App { class App {
@ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle; @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
onChange() { counter++; } onChange() { counter++; }
} }
TestBed.configureTestingModule({declarations: [App, ButtonToggle]}); TestBed.configureTestingModule({declarations: [App, ButtonToggle]});
@ -64,7 +64,7 @@ describe('outputs', () => {
@Component( @Component(
{template: '<button-toggle (change)="onChange()" (reset)="onReset()"></button-toggle>'}) {template: '<button-toggle (change)="onChange()" (reset)="onReset()"></button-toggle>'})
class App { class App {
@ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle; @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
onChange() { counter++; } onChange() { counter++; }
onReset() { resetCounter++; } onReset() { resetCounter++; }
} }
@ -82,7 +82,7 @@ describe('outputs', () => {
it('should eval component output expression when event is emitted', () => { it('should eval component output expression when event is emitted', () => {
@Component({template: '<button-toggle (change)="counter = counter + 1"></button-toggle>'}) @Component({template: '<button-toggle (change)="counter = counter + 1"></button-toggle>'})
class App { class App {
@ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle; @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
counter = 0; counter = 0;
} }
TestBed.configureTestingModule({declarations: [App, ButtonToggle]}); TestBed.configureTestingModule({declarations: [App, ButtonToggle]});
@ -102,7 +102,7 @@ describe('outputs', () => {
@Component( @Component(
{template: '<button-toggle *ngIf="condition" (change)="onChange()"></button-toggle>'}) {template: '<button-toggle *ngIf="condition" (change)="onChange()"></button-toggle>'})
class App { class App {
@ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle; @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
condition = true; condition = true;
onChange() { counter++; } onChange() { counter++; }
@ -133,7 +133,7 @@ describe('outputs', () => {
` `
}) })
class App { class App {
@ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle; @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
condition = true; condition = true;
condition2 = true; condition2 = true;
@ -168,8 +168,8 @@ describe('outputs', () => {
` `
}) })
class App { class App {
@ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle; @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
@ViewChild(DestroyComp, {static: false}) destroyComp !: DestroyComp; @ViewChild(DestroyComp) destroyComp !: DestroyComp;
condition = true; condition = true;
onClick() { clickCounter++; } onClick() { clickCounter++; }
@ -206,7 +206,7 @@ describe('outputs', () => {
@Component({template: '<button myButton (click)="onClick()">Click me</button>'}) @Component({template: '<button myButton (click)="onClick()">Click me</button>'})
class App { class App {
@ViewChild(MyButton, {static: false}) buttonDir !: MyButton; @ViewChild(MyButton) buttonDir !: MyButton;
onClick() { counter++; } onClick() { counter++; }
} }
TestBed.configureTestingModule({declarations: [App, MyButton]}); TestBed.configureTestingModule({declarations: [App, MyButton]});
@ -228,8 +228,8 @@ describe('outputs', () => {
@Component({template: '<button-toggle (change)="onChange()" otherDir></button-toggle>'}) @Component({template: '<button-toggle (change)="onChange()" otherDir></button-toggle>'})
class App { class App {
@ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle; @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
@ViewChild(OtherDir, {static: false}) otherDir !: OtherDir; @ViewChild(OtherDir) otherDir !: OtherDir;
onChange() { counter++; } onChange() { counter++; }
} }
TestBed.configureTestingModule({declarations: [App, ButtonToggle, OtherDir]}); TestBed.configureTestingModule({declarations: [App, ButtonToggle, OtherDir]});
@ -257,8 +257,8 @@ describe('outputs', () => {
'<button-toggle (change)="onChange()" otherChangeDir [change]="change"></button-toggle>' '<button-toggle (change)="onChange()" otherChangeDir [change]="change"></button-toggle>'
}) })
class App { class App {
@ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle; @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
@ViewChild(OtherChangeDir, {static: false}) otherDir !: OtherChangeDir; @ViewChild(OtherChangeDir) otherDir !: OtherChangeDir;
change = true; change = true;
onChange() { counter++; } onChange() { counter++; }

View File

@ -70,7 +70,7 @@ describe('pipe', () => {
template: `<div my-dir [dirProp]="'a'|double"></div>`, template: `<div my-dir [dirProp]="'a'|double"></div>`,
}) })
class App { class App {
@ViewChild(Dir, {static: false}) directive !: Dir; @ViewChild(Dir) directive !: Dir;
} }
TestBed.configureTestingModule({declarations: [App, DoublePipe, Dir]}); TestBed.configureTestingModule({declarations: [App, DoublePipe, Dir]});
@ -421,7 +421,7 @@ describe('pipe', () => {
}) })
class App { class App {
@Input() something: any; @Input() something: any;
@ViewChild(SomeComp, {static: false}) comp !: SomeComp; @ViewChild(SomeComp) comp !: SomeComp;
pipeValue = 10; pipeValue = 10;
displayValue = 0; displayValue = 0;
} }
@ -473,7 +473,7 @@ describe('pipe', () => {
}) })
class App { class App {
@Input() something: any; @Input() something: any;
@ViewChild(SomeComp, {static: false}) comp !: SomeComp; @ViewChild(SomeComp) comp !: SomeComp;
pipeValue = 10; pipeValue = 10;
displayValue = 0; displayValue = 0;
} }

View File

@ -177,7 +177,7 @@ describe('query logic', () => {
it('should support ViewChild query inherited from undecorated superclasses', () => { it('should support ViewChild query inherited from undecorated superclasses', () => {
class MyComp { class MyComp {
@ViewChild('foo', {static: false}) foo: any; @ViewChild('foo') foo: any;
} }
@Component({selector: 'sub-comp', template: '<div #foo></div>'}) @Component({selector: 'sub-comp', template: '<div #foo></div>'})
@ -193,7 +193,7 @@ describe('query logic', () => {
it('should support ViewChild query inherited from undecorated grand superclasses', () => { it('should support ViewChild query inherited from undecorated grand superclasses', () => {
class MySuperComp { class MySuperComp {
@ViewChild('foo', {static: false}) foo: any; @ViewChild('foo') foo: any;
} }
class MyComp extends MySuperComp {} class MyComp extends MySuperComp {}
@ -287,7 +287,7 @@ describe('query logic', () => {
` `
}) })
class App { class App {
@ViewChild(Required, {static: false}) requiredEl !: Required; @ViewChild(Required) requiredEl !: Required;
viewChildAvailableInAfterViewInit?: boolean; viewChildAvailableInAfterViewInit?: boolean;
ngAfterViewInit() { ngAfterViewInit() {
@ -529,7 +529,7 @@ describe('query logic', () => {
it('should support ContentChild query inherited from undecorated superclasses', () => { it('should support ContentChild query inherited from undecorated superclasses', () => {
class MyComp { class MyComp {
@ContentChild('foo', {static: false}) foo: any; @ContentChild('foo') foo: any;
} }
@Component({selector: 'sub-comp', template: '<ng-content></ng-content>'}) @Component({selector: 'sub-comp', template: '<ng-content></ng-content>'})
@ -538,7 +538,7 @@ describe('query logic', () => {
@Component({template: '<sub-comp><div #foo></div></sub-comp>'}) @Component({template: '<sub-comp><div #foo></div></sub-comp>'})
class App { class App {
@ViewChild(SubComp, {static: false}) subComp !: SubComp; @ViewChild(SubComp) subComp !: SubComp;
} }
TestBed.configureTestingModule({declarations: [App, SubComp]}); TestBed.configureTestingModule({declarations: [App, SubComp]});
@ -550,7 +550,7 @@ describe('query logic', () => {
it('should support ContentChild query inherited from undecorated grand superclasses', () => { it('should support ContentChild query inherited from undecorated grand superclasses', () => {
class MySuperComp { class MySuperComp {
@ContentChild('foo', {static: false}) foo: any; @ContentChild('foo') foo: any;
} }
class MyComp extends MySuperComp {} class MyComp extends MySuperComp {}
@ -561,7 +561,7 @@ describe('query logic', () => {
@Component({template: '<sub-comp><div #foo></div></sub-comp>'}) @Component({template: '<sub-comp><div #foo></div></sub-comp>'})
class App { class App {
@ViewChild(SubComp, {static: false}) subComp !: SubComp; @ViewChild(SubComp) subComp !: SubComp;
} }
TestBed.configureTestingModule({declarations: [App, SubComp]}); TestBed.configureTestingModule({declarations: [App, SubComp]});
@ -593,7 +593,7 @@ describe('query logic', () => {
` `
}) })
class App { class App {
@ViewChild(SubComp, {static: false}) subComp !: SubComp; @ViewChild(SubComp) subComp !: SubComp;
} }
TestBed.configureTestingModule({declarations: [App, SubComp, SomeDir]}); TestBed.configureTestingModule({declarations: [App, SubComp, SomeDir]});
@ -628,7 +628,7 @@ describe('query logic', () => {
` `
}) })
class App { class App {
@ViewChild(SubComp, {static: false}) subComp !: SubComp; @ViewChild(SubComp) subComp !: SubComp;
} }
TestBed.configureTestingModule({declarations: [App, SubComp, SomeDir]}); TestBed.configureTestingModule({declarations: [App, SubComp, SomeDir]});
@ -892,10 +892,10 @@ describe('query logic', () => {
`, `,
}) })
class TestComponent { class TestComponent {
@ViewChild(ViewContainerManipulatorDirective, {static: false}) @ViewChild(ViewContainerManipulatorDirective)
vc !: ViewContainerManipulatorDirective; vc !: ViewContainerManipulatorDirective;
@ViewChild('tpl1', {static: false}) tpl1 !: TemplateRef<any>; @ViewChild('tpl1') tpl1 !: TemplateRef<any>;
@ViewChild('tpl2', {static: false}) tpl2 !: TemplateRef<any>; @ViewChild('tpl2') tpl2 !: TemplateRef<any>;
@ViewChildren('foo') query !: QueryList<any>; @ViewChildren('foo') query !: QueryList<any>;
} }
@ -964,9 +964,9 @@ describe('query logic', () => {
`, `,
}) })
class TestComponent { class TestComponent {
@ViewChild('tpl', {static: false}) tpl !: TemplateRef<any>; @ViewChild('tpl') tpl !: TemplateRef<any>;
@ViewChild('vi0', {static: false}) vi0 !: ViewContainerManipulatorDirective; @ViewChild('vi0') vi0 !: ViewContainerManipulatorDirective;
@ViewChild('vi1', {static: false}) vi1 !: ViewContainerManipulatorDirective; @ViewChild('vi1') vi1 !: ViewContainerManipulatorDirective;
@ViewChildren('foo') query !: QueryList<any>; @ViewChildren('foo') query !: QueryList<any>;
} }
@ -1139,8 +1139,8 @@ function initWithTemplate(compType: Type<any>, template: string) {
@Component({selector: 'local-ref-query-component', template: '<ng-content></ng-content>'}) @Component({selector: 'local-ref-query-component', template: '<ng-content></ng-content>'})
class QueryComp { class QueryComp {
@ViewChild('viewQuery', {static: false}) viewChild !: any; @ViewChild('viewQuery') viewChild !: any;
@ContentChild('contentQuery', {static: false}) contentChild !: any; @ContentChild('contentQuery') contentChild !: any;
@ViewChildren('viewQuery') viewChildren !: QueryList<any>; @ViewChildren('viewQuery') viewChildren !: QueryList<any>;
@ContentChildren('contentQuery') contentChildren !: QueryList<any>; @ContentChildren('contentQuery') contentChildren !: QueryList<any>;
@ -1183,7 +1183,7 @@ class StaticViewQueryComp {
this._textDir = value; this._textDir = value;
} }
@ViewChild('foo', {static: false}) @ViewChild('foo')
get foo(): ElementRef { return this._foo; } get foo(): ElementRef { return this._foo; }
set foo(value: ElementRef) { set foo(value: ElementRef) {
@ -1208,7 +1208,7 @@ class SubclassStaticViewQueryComp extends StaticViewQueryComp {
@ViewChild('bar', {static: true}) @ViewChild('bar', {static: true})
bar !: ElementRef; bar !: ElementRef;
@ViewChild('baz', {static: false}) @ViewChild('baz')
baz !: ElementRef; baz !: ElementRef;
} }
@ -1227,7 +1227,7 @@ class StaticContentQueryComp {
this._textDir = value; this._textDir = value;
} }
@ContentChild('foo', {static: false}) @ContentChild('foo')
get foo(): ElementRef { return this._foo; } get foo(): ElementRef { return this._foo; }
set foo(value: ElementRef) { set foo(value: ElementRef) {
@ -1250,7 +1250,7 @@ class StaticContentQueryDir {
this._textDir = value; this._textDir = value;
} }
@ContentChild('foo', {static: false}) @ContentChild('foo')
get foo(): ElementRef { return this._foo; } get foo(): ElementRef { return this._foo; }
set foo(value: ElementRef) { set foo(value: ElementRef) {
@ -1264,7 +1264,7 @@ class SubclassStaticContentQueryComp extends StaticContentQueryComp {
@ContentChild('bar', {static: true}) @ContentChild('bar', {static: true})
bar !: ElementRef; bar !: ElementRef;
@ContentChild('baz', {static: false}) @ContentChild('baz')
baz !: ElementRef; baz !: ElementRef;
} }

View File

@ -753,7 +753,7 @@ describe('styling', () => {
template: '<span dir [classesInSchool]="classes" [styleOfClothing]="style"></span>', template: '<span dir [classesInSchool]="classes" [styleOfClothing]="style"></span>',
}) })
class App { class App {
@ViewChild(Dir, {static: false}) dir !: Dir; @ViewChild(Dir) dir !: Dir;
classes = 'math'; classes = 'math';
style = '80s'; style = '80s';
@ -1966,7 +1966,7 @@ describe('styling', () => {
class ParentCmp { class ParentCmp {
private _prop = ''; private _prop = '';
@ViewChild('template', {read: ViewContainerRef, static: false}) @ViewChild('template', {read: ViewContainerRef})
vcr: ViewContainerRef = null !; vcr: ViewContainerRef = null !;
private child: ComponentRef<ChildCmp> = null !; private child: ComponentRef<ChildCmp> = null !;
@ -2051,7 +2051,7 @@ describe('styling', () => {
class ParentCmp { class ParentCmp {
updateChild = false; updateChild = false;
@ViewChild('template', {read: ViewContainerRef, static: false}) @ViewChild('template', {read: ViewContainerRef})
vcr: ViewContainerRef = null !; vcr: ViewContainerRef = null !;
private child: ComponentRef<ChildCmp> = null !; private child: ComponentRef<ChildCmp> = null !;

View File

@ -37,7 +37,7 @@ describe('TemplateRef', () => {
` `
}) })
class App { class App {
@ViewChild(MenuContent, {static: false}) content !: MenuContent; @ViewChild(MenuContent) content !: MenuContent;
constructor(public viewContainerRef: ViewContainerRef) {} constructor(public viewContainerRef: ViewContainerRef) {}
} }

View File

@ -141,7 +141,7 @@ describe('ViewContainerRef', () => {
` `
}) })
class TestComp { class TestComp {
@ViewChild('container', {read: ViewContainerRef, static: false}) vcRef !: ViewContainerRef; @ViewChild('container', {read: ViewContainerRef}) vcRef !: ViewContainerRef;
constructor(public cfr: ComponentFactoryResolver) {} constructor(public cfr: ComponentFactoryResolver) {}
@ -2128,7 +2128,7 @@ class ViewContainerRefComp {
` `
}) })
class ViewContainerRefApp { class ViewContainerRefApp {
@ViewChild(ViewContainerRefComp, {static: false}) vcrComp !: ViewContainerRefComp; @ViewChild(ViewContainerRefComp) vcrComp !: ViewContainerRefComp;
} }
@Directive({selector: '[structDir]'}) @Directive({selector: '[structDir]'})

View File

@ -89,10 +89,10 @@ describe('view insertion', () => {
` `
}) })
class App { class App {
@ViewChild('container', {read: ViewContainerRef, static: false}) @ViewChild('container', {read: ViewContainerRef})
container: ViewContainerRef = null !; container: ViewContainerRef = null !;
@ViewChild('empty', {read: TemplateRef, static: false}) @ViewChild('empty', {read: TemplateRef})
empty: TemplateRef<any> = null !; empty: TemplateRef<any> = null !;
view0: EmbeddedViewRef<any> = null !; view0: EmbeddedViewRef<any> = null !;
@ -139,10 +139,10 @@ describe('view insertion', () => {
` `
}) })
class Comp { class Comp {
@ViewChild('container', {read: ViewContainerRef, static: false}) @ViewChild('container', {read: ViewContainerRef})
container: ViewContainerRef = null !; container: ViewContainerRef = null !;
@ViewChild('projection', {read: TemplateRef, static: false}) @ViewChild('projection', {read: TemplateRef})
projection: TemplateRef<any> = null !; projection: TemplateRef<any> = null !;
view0: EmbeddedViewRef<any> = null !; view0: EmbeddedViewRef<any> = null !;
@ -200,10 +200,10 @@ describe('view insertion', () => {
` `
}) })
class App { class App {
@ViewChild('container', {read: ViewContainerRef, static: false}) @ViewChild('container', {read: ViewContainerRef})
container: ViewContainerRef = null !; container: ViewContainerRef = null !;
@ViewChild('subContainer', {read: TemplateRef, static: false}) @ViewChild('subContainer', {read: TemplateRef})
subContainer: TemplateRef<any> = null !; subContainer: TemplateRef<any> = null !;
view0: EmbeddedViewRef<any> = null !; view0: EmbeddedViewRef<any> = null !;

View File

@ -376,7 +376,7 @@ const DEFAULT_COMPONENT_ID = '1';
] ]
}) })
class Cmp { class Cmp {
@ViewChild('element', {static: false}) @ViewChild('element')
element: any; element: any;
exp: any = ''; exp: any = '';
} }
@ -1463,7 +1463,7 @@ const DEFAULT_COMPONENT_ID = '1';
])] ])]
}) })
class Cmp { class Cmp {
@ViewChild('green', {static: false}) public element: any; @ViewChild('green') public element: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -1799,7 +1799,7 @@ const DEFAULT_COMPONENT_ID = '1';
class Cmp { class Cmp {
public exp: any; public exp: any;
@ViewChild('parent', {static: false}) public parentElement: any; @ViewChild('parent') public parentElement: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -1853,9 +1853,9 @@ const DEFAULT_COMPONENT_ID = '1';
public exp1: any; public exp1: any;
public exp2: any; public exp2: any;
@ViewChild('parent', {static: false}) public parent: any; @ViewChild('parent') public parent: any;
@ViewChild('child', {static: false}) public child: any; @ViewChild('child') public child: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -1910,11 +1910,11 @@ const DEFAULT_COMPONENT_ID = '1';
public exp1: any; public exp1: any;
public exp2: any; public exp2: any;
@ViewChild('parent', {static: false}) public parent: any; @ViewChild('parent') public parent: any;
@ViewChild('child1', {static: false}) public child1Elm: any; @ViewChild('child1') public child1Elm: any;
@ViewChild('child2', {static: false}) public child2Elm: any; @ViewChild('child2') public child2Elm: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -2269,7 +2269,7 @@ const DEFAULT_COMPONENT_ID = '1';
[transition(':enter', [style({opacity: 0}), animate('1s', style({opacity: 1}))])])] [transition(':enter', [style({opacity: 0}), animate('1s', style({opacity: 1}))])])]
}) })
class OuterCmp { class OuterCmp {
@ViewChild('inner', {static: false}) public inner: any; @ViewChild('inner') public inner: any;
public exp: any = null; public exp: any = null;
update() { this.exp = 'go'; } update() { this.exp = 'go'; }
@ -3260,7 +3260,7 @@ const DEFAULT_COMPONENT_ID = '1';
] ]
}) })
class Cmp { class Cmp {
@ViewChild('parent', {static: false}) public parentElm: any; @ViewChild('parent') public parentElm: any;
disableExp = false; disableExp = false;
exp = false; exp = false;
} }
@ -3351,7 +3351,7 @@ const DEFAULT_COMPONENT_ID = '1';
` `
}) })
class ParentCmp { class ParentCmp {
@ViewChild('child', {static: false}) public child: ChildCmp|null = null; @ViewChild('child') public child: ChildCmp|null = null;
disableExp = false; disableExp = false;
} }
@ -3467,7 +3467,7 @@ const DEFAULT_COMPONENT_ID = '1';
` `
}) })
class Cmp { class Cmp {
@ViewChild('container', {static: false}) public container: any; @ViewChild('container') public container: any;
disableExp = false; disableExp = false;
exp = ''; exp = '';

View File

@ -888,7 +888,7 @@ import {HostListener} from '../../src/metadata/directives';
] ]
}) })
class Cmp { class Cmp {
@ViewChild('container', {static: false}) public container: any; @ViewChild('container') public container: any;
public items: any[] = []; public items: any[] = [];
} }
@ -1202,9 +1202,9 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any = ''; public exp1: any = '';
public exp2: any = true; public exp2: any = true;
@ViewChild('ancestor', {static: false}) public ancestorElm: any; @ViewChild('ancestor') public ancestorElm: any;
@ViewChild('parent', {static: false}) public parentElm: any; @ViewChild('parent') public parentElm: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -1281,9 +1281,9 @@ import {HostListener} from '../../src/metadata/directives';
public exp2: any = ''; public exp2: any = '';
public parentExp: any = true; public parentExp: any = true;
@ViewChild('ancestor', {static: false}) public ancestorElm: any; @ViewChild('ancestor') public ancestorElm: any;
@ViewChild('parent', {static: false}) public parentElm: any; @ViewChild('parent') public parentElm: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -1637,7 +1637,7 @@ import {HostListener} from '../../src/metadata/directives';
class ParentCmp { class ParentCmp {
public exp: any; public exp: any;
@ViewChild('child', {static: false}) public child: any; @ViewChild('child') public child: any;
} }
@Component({ @Component({
@ -1849,9 +1849,9 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any; public exp1: any;
public exp2: any; public exp2: any;
@ViewChild('parent', {static: false}) public elm1: any; @ViewChild('parent') public elm1: any;
@ViewChild('child', {static: false}) public elm2: any; @ViewChild('child') public elm2: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -1911,7 +1911,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp: any; public exp: any;
public items: any[] = [0, 1, 2, 3, 4]; public items: any[] = [0, 1, 2, 3, 4];
@ViewChild('parent', {static: false}) public elm: any; @ViewChild('parent') public elm: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -1981,7 +1981,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp: any; public exp: any;
public items: any[] = [0, 1, 2, 3, 4]; public items: any[] = [0, 1, 2, 3, 4];
@ViewChild('parent', {static: false}) public elm: any; @ViewChild('parent') public elm: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -2034,7 +2034,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any; public exp1: any;
public exp2: any; public exp2: any;
@ViewChild('parent', {static: false}) public elm: any; @ViewChild('parent') public elm: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -2104,7 +2104,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any; public exp1: any;
public exp2: any; public exp2: any;
@ViewChild('parent', {static: false}) public elm: any; @ViewChild('parent') public elm: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -2157,7 +2157,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any; public exp1: any;
public exp2: any; public exp2: any;
@ViewChild('parent', {static: false}) public elm: any; @ViewChild('parent') public elm: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -2209,7 +2209,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any; public exp1: any;
public exp2: any; public exp2: any;
@ViewChild('parent', {static: false}) public elm: any; @ViewChild('parent') public elm: any;
} }
TestBed.configureTestingModule({declarations: [Cmp]}); TestBed.configureTestingModule({declarations: [Cmp]});
@ -2258,7 +2258,7 @@ import {HostListener} from '../../src/metadata/directives';
}) })
class ParentCmp { class ParentCmp {
public exp: boolean = true; public exp: boolean = true;
@ViewChild('child', {static: false}) public childElm: any; @ViewChild('child') public childElm: any;
public childEvent: any; public childEvent: any;
@ -2694,7 +2694,7 @@ import {HostListener} from '../../src/metadata/directives';
class ParentCmp { class ParentCmp {
public exp: any; public exp: any;
@ViewChild('child', {static: false}) public childCmp: any; @ViewChild('child') public childCmp: any;
} }
@Component({ @Component({
@ -2758,7 +2758,7 @@ import {HostListener} from '../../src/metadata/directives';
` `
}) })
class ParentCmp { class ParentCmp {
@ViewChild('child', {static: false}) public childCmp: any; @ViewChild('child') public childCmp: any;
public exp: any; public exp: any;
public log: string[] = []; public log: string[] = [];
@ -2936,7 +2936,7 @@ import {HostListener} from '../../src/metadata/directives';
class ParentCmp { class ParentCmp {
public exp: any; public exp: any;
@ViewChild('child', {static: false}) public childCmp: any; @ViewChild('child') public childCmp: any;
} }
@Component({ @Component({
@ -3015,13 +3015,13 @@ import {HostListener} from '../../src/metadata/directives';
class ParentCmp { class ParentCmp {
public exp: any; public exp: any;
@ViewChild('child', {static: false}) public innerCmp: any; @ViewChild('child') public innerCmp: any;
} }
@Component( @Component(
{selector: 'child-cmp', template: '<grandchild-cmp #grandchild></grandchild-cmp>'}) {selector: 'child-cmp', template: '<grandchild-cmp #grandchild></grandchild-cmp>'})
class ChildCmp { class ChildCmp {
@ViewChild('grandchild', {static: false}) public innerCmp: any; @ViewChild('grandchild') public innerCmp: any;
} }
@Component({ @Component({

View File

@ -165,7 +165,7 @@ import {TestBed} from '../../testing';
] ]
}) })
class Cmp { class Cmp {
@ViewChild('elm', {static: false}) public element: any; @ViewChild('elm') public element: any;
public myAnimationExp = ''; public myAnimationExp = '';
} }
@ -216,7 +216,7 @@ import {TestBed} from '../../testing';
] ]
}) })
class Cmp { class Cmp {
@ViewChild('elm', {static: false}) public element: any; @ViewChild('elm') public element: any;
public myAnimationExp = ''; public myAnimationExp = '';
} }

View File

@ -417,7 +417,7 @@ class SomeComponent {
@Component({template: '<ng-container #vc></ng-container>'}) @Component({template: '<ng-container #vc></ng-container>'})
class ContainerComp { class ContainerComp {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ViewChild('vc', {read: ViewContainerRef, static: false}) @ViewChild('vc', {read: ViewContainerRef})
vc !: ViewContainerRef; vc !: ViewContainerRef;
} }

View File

@ -167,7 +167,7 @@ class BankAccount {
` `
}) })
class SimpleContentComp { class SimpleContentComp {
@ViewChild('content', {static: false}) content !: ElementRef; @ViewChild('content') content !: ElementRef;
} }
@Component({ @Component({

View File

@ -752,7 +752,7 @@ describe('Query API', () => {
class AutoProjecting { class AutoProjecting {
// TODO(issue/24571): // TODO(issue/24571):
// remove '!'. // remove '!'.
@ContentChild(TemplateRef, {static: false}) @ContentChild(TemplateRef)
content !: TemplateRef<any>; content !: TemplateRef<any>;
// TODO(issue/24571): // TODO(issue/24571):
@ -784,7 +784,7 @@ describe('Query API', () => {
class AutoProjecting { class AutoProjecting {
// TODO(issue/24571): // TODO(issue/24571):
// remove '!'. // remove '!'.
@ContentChild(TemplateRef, {static: false}) @ContentChild(TemplateRef)
content !: TemplateRef<any>; content !: TemplateRef<any>;
// TODO(issue/24571): // TODO(issue/24571):
@ -839,7 +839,7 @@ class NeedsContentChild implements AfterContentInit, AfterContentChecked {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
_child !: TextDirective; _child !: TextDirective;
@ContentChild(TextDirective, {static: false}) @ContentChild(TextDirective)
set child(value) { set child(value) {
this._child = value; this._child = value;
this.logs.push(['setter', value ? value.text : null]); this.logs.push(['setter', value ? value.text : null]);
@ -856,7 +856,7 @@ class NeedsContentChild implements AfterContentInit, AfterContentChecked {
@Directive({selector: '[directive-needs-content-child]'}) @Directive({selector: '[directive-needs-content-child]'})
class DirectiveNeedsContentChild { class DirectiveNeedsContentChild {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ContentChild(TextDirective, {static: false}) child !: TextDirective; @ContentChild(TextDirective) child !: TextDirective;
} }
@Component({selector: 'needs-view-child', template: `<div *ngIf="shouldShow" text="foo"></div>`}) @Component({selector: 'needs-view-child', template: `<div *ngIf="shouldShow" text="foo"></div>`})
@ -867,7 +867,7 @@ class NeedsViewChild implements AfterViewInit, AfterViewChecked {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
_child !: TextDirective; _child !: TextDirective;
@ViewChild(TextDirective, {static: false}) @ViewChild(TextDirective)
set child(value) { set child(value) {
this._child = value; this._child = value;
this.logs.push(['setter', value ? value.text : null]); this.logs.push(['setter', value ? value.text : null]);
@ -917,13 +917,13 @@ class NeedsQuery {
@Component({selector: 'needs-four-queries', template: ''}) @Component({selector: 'needs-four-queries', template: ''})
class NeedsFourQueries { class NeedsFourQueries {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ContentChild(TextDirective, {static: false}) query1 !: TextDirective; @ContentChild(TextDirective) query1 !: TextDirective;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ContentChild(TextDirective, {static: false}) query2 !: TextDirective; @ContentChild(TextDirective) query2 !: TextDirective;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ContentChild(TextDirective, {static: false}) query3 !: TextDirective; @ContentChild(TextDirective) query3 !: TextDirective;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ContentChild(TextDirective, {static: false}) query4 !: TextDirective; @ContentChild(TextDirective) query4 !: TextDirective;
} }
@Component({ @Component({
@ -1042,9 +1042,9 @@ class NeedsContentChildrenWithRead {
@Component({selector: 'needs-content-child-read', template: ''}) @Component({selector: 'needs-content-child-read', template: ''})
class NeedsContentChildWithRead { class NeedsContentChildWithRead {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ContentChild('q', {read: TextDirective, static: false}) textDirChild !: TextDirective; @ContentChild('q', {read: TextDirective}) textDirChild !: TextDirective;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ContentChild('nonExisting', {read: TextDirective, static: false}) @ContentChild('nonExisting', {read: TextDirective})
nonExistingVar !: TextDirective; nonExistingVar !: TextDirective;
} }
@ -1089,17 +1089,17 @@ class NeedsViewChildrenWithRead {
}) })
class NeedsViewChildWithRead { class NeedsViewChildWithRead {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ViewChild('q', {read: TextDirective, static: false}) textDirChild !: TextDirective; @ViewChild('q', {read: TextDirective}) textDirChild !: TextDirective;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ViewChild('nonExisting', {read: TextDirective, static: false}) nonExistingVar !: TextDirective; @ViewChild('nonExisting', {read: TextDirective}) nonExistingVar !: TextDirective;
} }
@Component({selector: 'needs-viewcontainer-read', template: '<div #q></div>'}) @Component({selector: 'needs-viewcontainer-read', template: '<div #q></div>'})
class NeedsViewContainerWithRead { class NeedsViewContainerWithRead {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ViewChild('q', {read: ViewContainerRef, static: false}) vc !: ViewContainerRef; @ViewChild('q', {read: ViewContainerRef}) vc !: ViewContainerRef;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ViewChild('nonExisting', {read: ViewContainerRef, static: false}) @ViewChild('nonExisting', {read: ViewContainerRef})
nonExistingVar !: ViewContainerRef; nonExistingVar !: ViewContainerRef;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ContentChild(TemplateRef, {static: true}) template !: TemplateRef<Object>; @ContentChild(TemplateRef, {static: true}) template !: TemplateRef<Object>;
@ -1128,7 +1128,7 @@ class ManualProjecting {
@ContentChild(TemplateRef, {static: true}) template !: TemplateRef<any>; @ContentChild(TemplateRef, {static: true}) template !: TemplateRef<any>;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ViewChild('vc', {read: ViewContainerRef, static: false}) @ViewChild('vc', {read: ViewContainerRef})
vc !: ViewContainerRef; vc !: ViewContainerRef;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.

View File

@ -83,13 +83,13 @@ class Simple {
@Component({selector: 'view-child-type-selector', template: ''}) @Component({selector: 'view-child-type-selector', template: ''})
class ViewChildTypeSelectorComponent { class ViewChildTypeSelectorComponent {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ViewChild(Simple, {static: false}) child !: Simple; @ViewChild(Simple) child !: Simple;
} }
@Component({selector: 'view-child-string-selector', template: ''}) @Component({selector: 'view-child-string-selector', template: ''})
class ViewChildStringSelectorComponent { class ViewChildStringSelectorComponent {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
@ViewChild('child', {static: false}) child !: ElementRef; @ViewChild('child') child !: ElementRef;
} }
@Component({selector: 'view-children-type-selector', template: ''}) @Component({selector: 'view-children-type-selector', template: ''})

View File

@ -297,7 +297,7 @@ ivyEnabled && describe('render3 jit', () => {
it('should compile ContentChild query with string predicate on a directive', () => { it('should compile ContentChild query with string predicate on a directive', () => {
@Directive({selector: '[test]'}) @Directive({selector: '[test]'})
class TestDirective { class TestDirective {
@ContentChild('foo', {static: false}) foo: ElementRef|undefined; @ContentChild('foo') foo: ElementRef|undefined;
} }
expect((TestDirective as any).ɵdir.contentQueries).not.toBeNull(); expect((TestDirective as any).ɵdir.contentQueries).not.toBeNull();
@ -319,7 +319,7 @@ ivyEnabled && describe('render3 jit', () => {
@Directive({selector: '[test]'}) @Directive({selector: '[test]'})
class TestDirective { class TestDirective {
@ContentChild(SomeDir, {static: false}) dir: SomeDir|undefined; @ContentChild(SomeDir) dir: SomeDir|undefined;
} }
expect((TestDirective as any).ɵdir.contentQueries).not.toBeNull(); expect((TestDirective as any).ɵdir.contentQueries).not.toBeNull();
@ -328,7 +328,7 @@ ivyEnabled && describe('render3 jit', () => {
it('should compile ViewChild query on a component', () => { it('should compile ViewChild query on a component', () => {
@Component({selector: 'test', template: ''}) @Component({selector: 'test', template: ''})
class TestComponent { class TestComponent {
@ViewChild('foo', {static: false}) foo: ElementRef|undefined; @ViewChild('foo') foo: ElementRef|undefined;
} }
expect((TestComponent as any).ɵcmp.foo).not.toBeNull(); expect((TestComponent as any).ɵcmp.foo).not.toBeNull();

View File

@ -21,7 +21,7 @@ export class Pane {
` `
}) })
export class Tab { export class Tab {
@ContentChild(Pane, {static: false}) pane !: Pane; @ContentChild(Pane) pane !: Pane;
} }
@Component({ @Component({

View File

@ -15,7 +15,7 @@ class ChildDirective {
@Directive({selector: 'someDir'}) @Directive({selector: 'someDir'})
class SomeDir implements AfterContentInit { class SomeDir implements AfterContentInit {
@ContentChild(ChildDirective, {static: false}) contentChild !: ChildDirective; @ContentChild(ChildDirective) contentChild !: ChildDirective;
ngAfterContentInit() { ngAfterContentInit() {
// contentChild is set // contentChild is set

View File

@ -26,7 +26,7 @@ export class Pane {
`, `,
}) })
export class ViewChildComp { export class ViewChildComp {
@ViewChild(Pane, {static: false}) @ViewChild(Pane)
set pane(v: Pane) { set pane(v: Pane) {
setTimeout(() => { this.selectedPane = v.id; }, 0); setTimeout(() => { this.selectedPane = v.id; }, 0);
} }

View File

@ -15,7 +15,7 @@ class ChildDirective {
@Component({selector: 'someCmp', templateUrl: 'someCmp.html'}) @Component({selector: 'someCmp', templateUrl: 'someCmp.html'})
class SomeCmp implements AfterViewInit { class SomeCmp implements AfterViewInit {
@ViewChild(ChildDirective, {static: false}) child !: ChildDirective; @ViewChild(ChildDirective) child !: ChildDirective;
ngAfterViewInit() { ngAfterViewInit() {
// child is set // child is set

View File

@ -178,7 +178,7 @@ import {el} from '../../testing/src/browser_util';
}) })
class Cmp { class Cmp {
exp: any; exp: any;
@ViewChild('elm', {static: false}) public element: any; @ViewChild('elm') public element: any;
} }
TestBed.configureTestingModule({ TestBed.configureTestingModule({
@ -223,11 +223,11 @@ import {el} from '../../testing/src/browser_util';
exp2: any = true; exp2: any = true;
exp3: any = true; exp3: any = true;
@ViewChild('elm1', {static: false}) public elm1: any; @ViewChild('elm1') public elm1: any;
@ViewChild('elm2', {static: false}) public elm2: any; @ViewChild('elm2') public elm2: any;
@ViewChild('elm3', {static: false}) public elm3: any; @ViewChild('elm3') public elm3: any;
} }
TestBed.configureTestingModule({ TestBed.configureTestingModule({

View File

@ -51,7 +51,7 @@ import {el} from '../../testing/src/browser_util';
template: '...', template: '...',
}) })
class Cmp { class Cmp {
@ViewChild('target', {static: false}) public target: any; @ViewChild('target') public target: any;
constructor(public builder: AnimationBuilder) {} constructor(public builder: AnimationBuilder) {}