@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {AfterViewInit, Component, ContentChild, ContentChildren, Directive, ElementRef, Input, QueryList, TemplateRef, Type, ViewChild, ViewChildren, ViewContainerRef, ViewRef, forwardRef} from '@angular/core';
|
||||
import {AfterViewInit, Component, ContentChild, ContentChildren, Directive, ElementRef, forwardRef, Input, QueryList, TemplateRef, Type, ViewChild, ViewChildren, ViewContainerRef, ViewRef} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {By} from '@angular/platform-browser';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
@ -215,7 +215,7 @@ describe('query logic', () => {
|
||||
}
|
||||
|
||||
class MyComp {
|
||||
@ViewChildren(SomeDir) foo !: QueryList<SomeDir>;
|
||||
@ViewChildren(SomeDir) foo!: QueryList<SomeDir>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -242,7 +242,7 @@ describe('query logic', () => {
|
||||
}
|
||||
|
||||
class MySuperComp {
|
||||
@ViewChildren(SomeDir) foo !: QueryList<SomeDir>;
|
||||
@ViewChildren(SomeDir) foo!: QueryList<SomeDir>;
|
||||
}
|
||||
|
||||
class MyComp extends MySuperComp {}
|
||||
@ -275,7 +275,7 @@ describe('query logic', () => {
|
||||
template: `<ng-container [ngTemplateOutlet]="content"></ng-container>`
|
||||
})
|
||||
class Insertion {
|
||||
@Input() content !: TemplateRef<{}>;
|
||||
@Input() content!: TemplateRef<{}>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -287,7 +287,7 @@ describe('query logic', () => {
|
||||
`
|
||||
})
|
||||
class App {
|
||||
@ViewChild(Required) requiredEl !: Required;
|
||||
@ViewChild(Required) requiredEl!: Required;
|
||||
viewChildAvailableInAfterViewInit?: boolean;
|
||||
|
||||
ngAfterViewInit() {
|
||||
@ -300,7 +300,6 @@ describe('query logic', () => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.componentInstance.viewChildAvailableInAfterViewInit).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('content queries', () => {
|
||||
@ -538,7 +537,7 @@ describe('query logic', () => {
|
||||
|
||||
@Component({template: '<sub-comp><div #foo></div></sub-comp>'})
|
||||
class App {
|
||||
@ViewChild(SubComp) subComp !: SubComp;
|
||||
@ViewChild(SubComp) subComp!: SubComp;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [App, SubComp]});
|
||||
@ -561,7 +560,7 @@ describe('query logic', () => {
|
||||
|
||||
@Component({template: '<sub-comp><div #foo></div></sub-comp>'})
|
||||
class App {
|
||||
@ViewChild(SubComp) subComp !: SubComp;
|
||||
@ViewChild(SubComp) subComp!: SubComp;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [App, SubComp]});
|
||||
@ -577,7 +576,7 @@ describe('query logic', () => {
|
||||
}
|
||||
|
||||
class MyComp {
|
||||
@ContentChildren(SomeDir) foo !: QueryList<SomeDir>;
|
||||
@ContentChildren(SomeDir) foo!: QueryList<SomeDir>;
|
||||
}
|
||||
|
||||
@Component({selector: 'sub-comp', template: '<ng-content></ng-content>'})
|
||||
@ -593,7 +592,7 @@ describe('query logic', () => {
|
||||
`
|
||||
})
|
||||
class App {
|
||||
@ViewChild(SubComp) subComp !: SubComp;
|
||||
@ViewChild(SubComp) subComp!: SubComp;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [App, SubComp, SomeDir]});
|
||||
@ -610,7 +609,7 @@ describe('query logic', () => {
|
||||
}
|
||||
|
||||
class MySuperComp {
|
||||
@ContentChildren(SomeDir) foo !: QueryList<SomeDir>;
|
||||
@ContentChildren(SomeDir) foo!: QueryList<SomeDir>;
|
||||
}
|
||||
|
||||
class MyComp extends MySuperComp {}
|
||||
@ -628,7 +627,7 @@ describe('query logic', () => {
|
||||
`
|
||||
})
|
||||
class App {
|
||||
@ViewChild(SubComp) subComp !: SubComp;
|
||||
@ViewChild(SubComp) subComp!: SubComp;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [App, SubComp, SomeDir]});
|
||||
@ -657,7 +656,7 @@ describe('query logic', () => {
|
||||
template: '',
|
||||
})
|
||||
class ShallowComp {
|
||||
@ContentChildren('foo', {descendants: false}) foos !: QueryList<ElementRef>;
|
||||
@ContentChildren('foo', {descendants: false}) foos!: QueryList<ElementRef>;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule(
|
||||
@ -666,7 +665,7 @@ describe('query logic', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const shallowComp = fixture.debugElement.query(By.directive(ShallowComp)).componentInstance;
|
||||
const queryList = shallowComp !.foos;
|
||||
const queryList = shallowComp!.foos;
|
||||
expect(queryList.length).toBe(0);
|
||||
|
||||
fixture.componentInstance.showing = true;
|
||||
@ -691,24 +690,24 @@ describe('query logic', () => {
|
||||
});
|
||||
|
||||
describe('descendants: false (default)', () => {
|
||||
|
||||
/**
|
||||
* A helper function to check if a given object looks like ElementRef. It is used in place of
|
||||
* the `instanceof ElementRef` check since ivy returns a type that looks like ElementRef (have
|
||||
* the same properties but doesn't pass the instanceof ElementRef test)
|
||||
*/
|
||||
function isElementRefLike(result: any): boolean { return result.nativeElement != null; }
|
||||
function isElementRefLike(result: any): boolean {
|
||||
return result.nativeElement != null;
|
||||
}
|
||||
|
||||
it('should match directives on elements that used to be wrapped by a required parent in HTML parser',
|
||||
() => {
|
||||
|
||||
@Directive({selector: '[myDef]'})
|
||||
class MyDef {
|
||||
}
|
||||
|
||||
@Component({selector: 'my-container', template: ``})
|
||||
class MyContainer {
|
||||
@ContentChildren(MyDef) myDefs !: QueryList<MyDef>;
|
||||
@ContentChildren(MyDef) myDefs!: QueryList<MyDef>;
|
||||
}
|
||||
@Component(
|
||||
{selector: 'test-cmpt', template: `<my-container><tr myDef></tr></my-container>`})
|
||||
@ -724,10 +723,9 @@ describe('query logic', () => {
|
||||
});
|
||||
|
||||
it('should match elements with local refs inside <ng-container>', () => {
|
||||
|
||||
@Component({selector: 'needs-target', template: ``})
|
||||
class NeedsTarget {
|
||||
@ContentChildren('target') targets !: QueryList<ElementRef>;
|
||||
@ContentChildren('target') targets!: QueryList<ElementRef>;
|
||||
}
|
||||
@Component({
|
||||
selector: 'test-cmpt',
|
||||
@ -752,10 +750,9 @@ describe('query logic', () => {
|
||||
});
|
||||
|
||||
it('should match elements with local refs inside nested <ng-container>', () => {
|
||||
|
||||
@Component({selector: 'needs-target', template: ``})
|
||||
class NeedsTarget {
|
||||
@ContentChildren('target') targets !: QueryList<ElementRef>;
|
||||
@ContentChildren('target') targets!: QueryList<ElementRef>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -791,7 +788,7 @@ describe('query logic', () => {
|
||||
|
||||
@Component({selector: 'needs-target', template: ``})
|
||||
class NeedsTarget {
|
||||
@ContentChildren(TargetDir) targets !: QueryList<HTMLElement>;
|
||||
@ContentChildren(TargetDir) targets!: QueryList<HTMLElement>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -823,7 +820,7 @@ describe('query logic', () => {
|
||||
|
||||
@Component({selector: 'needs-target', template: ``})
|
||||
class NeedsTarget {
|
||||
@ContentChildren(TargetDir) targets !: QueryList<HTMLElement>;
|
||||
@ContentChildren(TargetDir) targets!: QueryList<HTMLElement>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -859,7 +856,7 @@ describe('query logic', () => {
|
||||
|
||||
@Directive({selector: '[needs-target]'})
|
||||
class NeedsTarget {
|
||||
@ContentChildren(TargetDir) targets !: QueryList<HTMLElement>;
|
||||
@ContentChildren(TargetDir) targets!: QueryList<HTMLElement>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -893,8 +890,8 @@ describe('query logic', () => {
|
||||
|
||||
@Component({selector: 'needs-target', template: ``})
|
||||
class NeedsTarget {
|
||||
@ContentChildren(TargetDir) dirTargets !: QueryList<TargetDir>;
|
||||
@ContentChildren('target') localRefsTargets !: QueryList<ElementRef>;
|
||||
@ContentChildren(TargetDir) dirTargets!: QueryList<TargetDir>;
|
||||
@ContentChildren('target') localRefsTargets!: QueryList<ElementRef>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -931,7 +928,7 @@ describe('query logic', () => {
|
||||
|
||||
@Component({selector: 'needs-target', template: ``})
|
||||
class NeedsTarget {
|
||||
@ContentChildren(TargetDir) targets !: QueryList<HTMLElement>;
|
||||
@ContentChildren(TargetDir) targets!: QueryList<HTMLElement>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -963,7 +960,6 @@ describe('query logic', () => {
|
||||
|
||||
|
||||
describe('observable interface', () => {
|
||||
|
||||
it('should allow observing changes to query list', () => {
|
||||
const fixture = TestBed.createComponent(QueryCompWithChanges);
|
||||
let changes = 0;
|
||||
@ -983,13 +979,10 @@ describe('query logic', () => {
|
||||
fixture.detectChanges();
|
||||
expect(changes).toBe(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('view boundaries', () => {
|
||||
|
||||
describe('ViewContainerRef', () => {
|
||||
|
||||
@Directive({selector: '[vc]', exportAs: 'vc'})
|
||||
class ViewContainerManipulatorDirective {
|
||||
constructor(private _vcRef: ViewContainerRef) {}
|
||||
@ -998,9 +991,13 @@ describe('query logic', () => {
|
||||
return this._vcRef.createEmbeddedView(tpl, ctx, idx);
|
||||
}
|
||||
|
||||
remove(index?: number) { this._vcRef.remove(index); }
|
||||
remove(index?: number) {
|
||||
this._vcRef.remove(index);
|
||||
}
|
||||
|
||||
move(viewRef: ViewRef, index: number) { this._vcRef.move(viewRef, index); }
|
||||
move(viewRef: ViewRef, index: number) {
|
||||
this._vcRef.move(viewRef, index);
|
||||
}
|
||||
}
|
||||
|
||||
it('should report results in views inserted / removed by ngIf', () => {
|
||||
@ -1014,7 +1011,7 @@ describe('query logic', () => {
|
||||
})
|
||||
class TestComponent {
|
||||
value: boolean = false;
|
||||
@ViewChildren('foo') query !: QueryList<any>;
|
||||
@ViewChildren('foo') query!: QueryList<any>;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [TestComponent]});
|
||||
@ -1045,7 +1042,7 @@ describe('query logic', () => {
|
||||
})
|
||||
class TestComponent {
|
||||
value: string[]|undefined;
|
||||
@ViewChildren('foo') query !: QueryList<any>;
|
||||
@ViewChildren('foo') query!: QueryList<any>;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [TestComponent]});
|
||||
@ -1082,7 +1079,6 @@ describe('query logic', () => {
|
||||
*/
|
||||
it('should notify on changes when a given view is removed and re-inserted at the same index',
|
||||
() => {
|
||||
|
||||
@Component({
|
||||
selector: 'test-comp',
|
||||
template: `
|
||||
@ -1093,10 +1089,9 @@ describe('query logic', () => {
|
||||
class TestComponent implements AfterViewInit {
|
||||
queryListNotificationCounter = 0;
|
||||
|
||||
@ViewChild(ViewContainerManipulatorDirective)
|
||||
vc !: ViewContainerManipulatorDirective;
|
||||
@ViewChild('tpl') tpl !: TemplateRef<any>;
|
||||
@ViewChildren('foo') query !: QueryList<any>;
|
||||
@ViewChild(ViewContainerManipulatorDirective) vc!: ViewContainerManipulatorDirective;
|
||||
@ViewChild('tpl') tpl!: TemplateRef<any>;
|
||||
@ViewChildren('foo') query!: QueryList<any>;
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.query.changes.subscribe(() => this.queryListNotificationCounter++);
|
||||
@ -1125,13 +1120,13 @@ describe('query logic', () => {
|
||||
it('should support a mix of content queries from the declaration and embedded view', () => {
|
||||
@Directive({selector: '[query-for-lots-of-content]'})
|
||||
class QueryForLotsOfContent {
|
||||
@ContentChildren('foo', {descendants: true}) foos1 !: QueryList<ElementRef>;
|
||||
@ContentChildren('foo', {descendants: true}) foos2 !: QueryList<ElementRef>;
|
||||
@ContentChildren('foo', {descendants: true}) foos1!: QueryList<ElementRef>;
|
||||
@ContentChildren('foo', {descendants: true}) foos2!: QueryList<ElementRef>;
|
||||
}
|
||||
|
||||
@Directive({selector: '[query-for-content]'})
|
||||
class QueryForContent {
|
||||
@ContentChildren('foo') foos !: QueryList<ElementRef>;
|
||||
@ContentChildren('foo') foos!: QueryList<ElementRef>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -1192,11 +1187,10 @@ describe('query logic', () => {
|
||||
`,
|
||||
})
|
||||
class TestComponent {
|
||||
@ViewChild(ViewContainerManipulatorDirective)
|
||||
vc !: ViewContainerManipulatorDirective;
|
||||
@ViewChild('tpl1') tpl1 !: TemplateRef<any>;
|
||||
@ViewChild('tpl2') tpl2 !: TemplateRef<any>;
|
||||
@ViewChildren('foo') query !: QueryList<any>;
|
||||
@ViewChild(ViewContainerManipulatorDirective) vc!: ViewContainerManipulatorDirective;
|
||||
@ViewChild('tpl1') tpl1!: TemplateRef<any>;
|
||||
@ViewChild('tpl2') tpl2!: TemplateRef<any>;
|
||||
@ViewChildren('foo') query!: QueryList<any>;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule(
|
||||
@ -1210,8 +1204,8 @@ describe('query logic', () => {
|
||||
expect(queryList.length).toBe(1);
|
||||
expect(queryList.first.nativeElement.getAttribute('id')).toBe('middle');
|
||||
|
||||
vc.insertTpl(tpl1 !, {idx: 0}, 0);
|
||||
vc.insertTpl(tpl2 !, {idx: 1}, 1);
|
||||
vc.insertTpl(tpl1!, {idx: 0}, 0);
|
||||
vc.insertTpl(tpl2!, {idx: 1}, 1);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(queryList.length).toBe(3);
|
||||
@ -1220,7 +1214,7 @@ describe('query logic', () => {
|
||||
expect(qListArr[1].nativeElement.getAttribute('id')).toBe('middle');
|
||||
expect(qListArr[2].nativeElement.getAttribute('id')).toBe('foo2_1');
|
||||
|
||||
vc.insertTpl(tpl1 !, {idx: 1}, 1);
|
||||
vc.insertTpl(tpl1!, {idx: 1}, 1);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(queryList.length).toBe(4);
|
||||
@ -1264,10 +1258,10 @@ describe('query logic', () => {
|
||||
`,
|
||||
})
|
||||
class TestComponent {
|
||||
@ViewChild('tpl') tpl !: TemplateRef<any>;
|
||||
@ViewChild('vi0') vi0 !: ViewContainerManipulatorDirective;
|
||||
@ViewChild('vi1') vi1 !: ViewContainerManipulatorDirective;
|
||||
@ViewChildren('foo') query !: QueryList<any>;
|
||||
@ViewChild('tpl') tpl!: TemplateRef<any>;
|
||||
@ViewChild('vi0') vi0!: ViewContainerManipulatorDirective;
|
||||
@ViewChild('vi1') vi1!: ViewContainerManipulatorDirective;
|
||||
@ViewChildren('foo') query!: QueryList<any>;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule(
|
||||
@ -1280,8 +1274,8 @@ describe('query logic', () => {
|
||||
|
||||
expect(queryList.length).toBe(0);
|
||||
|
||||
vi0.insertTpl(tpl !, {idx: 0, container_idx: 0}, 0);
|
||||
vi1.insertTpl(tpl !, {idx: 0, container_idx: 1}, 0);
|
||||
vi0.insertTpl(tpl!, {idx: 0, container_idx: 0}, 0);
|
||||
vi1.insertTpl(tpl!, {idx: 0, container_idx: 1}, 0);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(queryList.length).toBe(2);
|
||||
@ -1315,7 +1309,7 @@ describe('query logic', () => {
|
||||
})
|
||||
class MyApp {
|
||||
show = false;
|
||||
@ViewChildren('foo') query !: QueryList<any>;
|
||||
@ViewChildren('foo') query!: QueryList<any>;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [MyApp], imports: [CommonModule]});
|
||||
@ -1334,14 +1328,11 @@ describe('query logic', () => {
|
||||
fixture.detectChanges();
|
||||
expect(queryList.length).toBe(0);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe('non-regression', () => {
|
||||
|
||||
it('should query by provider super-type in an embedded view', () => {
|
||||
|
||||
@Directive({selector: '[child]'})
|
||||
class Child {
|
||||
}
|
||||
@ -1356,7 +1347,7 @@ describe('query logic', () => {
|
||||
`<ng-template [ngIf]="true"><ng-template [ngIf]="true"><div parent></div></ng-template></ng-template>`
|
||||
})
|
||||
class TestCmpt {
|
||||
@ViewChildren(Child) instances !: QueryList<Child>;
|
||||
@ViewChildren(Child) instances!: QueryList<Child>;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [TestCmpt, Parent, Child]});
|
||||
@ -1367,7 +1358,6 @@ describe('query logic', () => {
|
||||
});
|
||||
|
||||
it('should flatten multi-provider results', () => {
|
||||
|
||||
class MyClass {}
|
||||
|
||||
@Component({
|
||||
@ -1381,7 +1371,7 @@ describe('query logic', () => {
|
||||
|
||||
@Component({selector: 'test-cmpt', template: `<with-multi-provider></with-multi-provider>`})
|
||||
class TestCmpt {
|
||||
@ViewChildren(MyClass) queryResults !: QueryList<WithMultiProvider>;
|
||||
@ViewChildren(MyClass) queryResults!: QueryList<WithMultiProvider>;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [TestCmpt, WithMultiProvider]});
|
||||
@ -1393,7 +1383,6 @@ describe('query logic', () => {
|
||||
});
|
||||
|
||||
it('should flatten multi-provider results when crossing ng-template', () => {
|
||||
|
||||
class MyClass {}
|
||||
|
||||
@Component({
|
||||
@ -1413,7 +1402,7 @@ describe('query logic', () => {
|
||||
`
|
||||
})
|
||||
class TestCmpt {
|
||||
@ViewChildren(MyClass) queryResults !: QueryList<WithMultiProvider>;
|
||||
@ViewChildren(MyClass) queryResults!: QueryList<WithMultiProvider>;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [TestCmpt, WithMultiProvider]});
|
||||
@ -1444,7 +1433,7 @@ describe('query logic', () => {
|
||||
`
|
||||
})
|
||||
class App {
|
||||
@ViewChild(GroupDir) group !: GroupDir;
|
||||
@ViewChild(GroupDir) group!: GroupDir;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule(
|
||||
@ -1481,7 +1470,7 @@ describe('query logic', () => {
|
||||
`
|
||||
})
|
||||
class App {
|
||||
@ViewChildren(GroupDir) groups !: QueryList<GroupDir>;
|
||||
@ViewChildren(GroupDir) groups!: QueryList<GroupDir>;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule(
|
||||
@ -1497,9 +1486,7 @@ describe('query logic', () => {
|
||||
expect(groups[1]).toBeAnInstanceOf(GroupDir);
|
||||
expect(groups[2]).toBeUndefined();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function initWithTemplate(compType: Type<any>, template: string) {
|
||||
@ -1511,11 +1498,11 @@ function initWithTemplate(compType: Type<any>, template: string) {
|
||||
|
||||
@Component({selector: 'local-ref-query-component', template: '<ng-content></ng-content>'})
|
||||
class QueryComp {
|
||||
@ViewChild('viewQuery') viewChild !: any;
|
||||
@ContentChild('contentQuery') contentChild !: any;
|
||||
@ViewChild('viewQuery') viewChild!: any;
|
||||
@ContentChild('contentQuery') contentChild!: any;
|
||||
|
||||
@ViewChildren('viewQuery') viewChildren !: QueryList<any>;
|
||||
@ContentChildren('contentQuery') contentChildren !: QueryList<any>;
|
||||
@ViewChildren('viewQuery') viewChildren!: QueryList<any>;
|
||||
@ContentChildren('contentQuery') contentChildren!: QueryList<any>;
|
||||
}
|
||||
|
||||
@Component({selector: 'app-comp', template: ``})
|
||||
@ -1543,12 +1530,14 @@ class TextDirective {
|
||||
`
|
||||
})
|
||||
class StaticViewQueryComp {
|
||||
private _textDir !: TextDirective;
|
||||
private _foo !: ElementRef;
|
||||
private _textDir!: TextDirective;
|
||||
private _foo!: ElementRef;
|
||||
setEvents: string[] = [];
|
||||
|
||||
@ViewChild(TextDirective, {static: true})
|
||||
get textDir(): TextDirective { return this._textDir; }
|
||||
get textDir(): TextDirective {
|
||||
return this._textDir;
|
||||
}
|
||||
|
||||
set textDir(value: TextDirective) {
|
||||
this.setEvents.push('textDir set');
|
||||
@ -1556,7 +1545,9 @@ class StaticViewQueryComp {
|
||||
}
|
||||
|
||||
@ViewChild('foo')
|
||||
get foo(): ElementRef { return this._foo; }
|
||||
get foo(): ElementRef {
|
||||
return this._foo;
|
||||
}
|
||||
|
||||
set foo(value: ElementRef) {
|
||||
this.setEvents.push('foo set');
|
||||
@ -1577,22 +1568,22 @@ class StaticViewQueryComp {
|
||||
`
|
||||
})
|
||||
class SubclassStaticViewQueryComp extends StaticViewQueryComp {
|
||||
@ViewChild('bar', {static: true})
|
||||
bar !: ElementRef;
|
||||
@ViewChild('bar', {static: true}) bar!: ElementRef;
|
||||
|
||||
@ViewChild('baz')
|
||||
baz !: ElementRef;
|
||||
@ViewChild('baz') baz!: ElementRef;
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'static-content-query-comp', template: `<ng-content></ng-content>`})
|
||||
class StaticContentQueryComp {
|
||||
private _textDir !: TextDirective;
|
||||
private _foo !: ElementRef;
|
||||
private _textDir!: TextDirective;
|
||||
private _foo!: ElementRef;
|
||||
setEvents: string[] = [];
|
||||
|
||||
@ContentChild(TextDirective, {static: true})
|
||||
get textDir(): TextDirective { return this._textDir; }
|
||||
get textDir(): TextDirective {
|
||||
return this._textDir;
|
||||
}
|
||||
|
||||
set textDir(value: TextDirective) {
|
||||
this.setEvents.push('textDir set');
|
||||
@ -1600,7 +1591,9 @@ class StaticContentQueryComp {
|
||||
}
|
||||
|
||||
@ContentChild('foo')
|
||||
get foo(): ElementRef { return this._foo; }
|
||||
get foo(): ElementRef {
|
||||
return this._foo;
|
||||
}
|
||||
|
||||
set foo(value: ElementRef) {
|
||||
this.setEvents.push('foo set');
|
||||
@ -1610,12 +1603,14 @@ class StaticContentQueryComp {
|
||||
|
||||
@Directive({selector: '[staticContentQueryDir]'})
|
||||
class StaticContentQueryDir {
|
||||
private _textDir !: TextDirective;
|
||||
private _foo !: ElementRef;
|
||||
private _textDir!: TextDirective;
|
||||
private _foo!: ElementRef;
|
||||
setEvents: string[] = [];
|
||||
|
||||
@ContentChild(TextDirective, {static: true})
|
||||
get textDir(): TextDirective { return this._textDir; }
|
||||
get textDir(): TextDirective {
|
||||
return this._textDir;
|
||||
}
|
||||
|
||||
set textDir(value: TextDirective) {
|
||||
this.setEvents.push('textDir set');
|
||||
@ -1623,7 +1618,9 @@ class StaticContentQueryDir {
|
||||
}
|
||||
|
||||
@ContentChild('foo')
|
||||
get foo(): ElementRef { return this._foo; }
|
||||
get foo(): ElementRef {
|
||||
return this._foo;
|
||||
}
|
||||
|
||||
set foo(value: ElementRef) {
|
||||
this.setEvents.push('foo set');
|
||||
@ -1633,11 +1630,9 @@ class StaticContentQueryDir {
|
||||
|
||||
@Component({selector: 'subclass-static-content-query-comp', template: `<ng-content></ng-content>`})
|
||||
class SubclassStaticContentQueryComp extends StaticContentQueryComp {
|
||||
@ContentChild('bar', {static: true})
|
||||
bar !: ElementRef;
|
||||
@ContentChild('bar', {static: true}) bar!: ElementRef;
|
||||
|
||||
@ContentChild('baz')
|
||||
baz !: ElementRef;
|
||||
@ContentChild('baz') baz!: ElementRef;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@ -1647,7 +1642,7 @@ class SubclassStaticContentQueryComp extends StaticContentQueryComp {
|
||||
`
|
||||
})
|
||||
export class QueryCompWithChanges {
|
||||
@ViewChildren('foo') foos !: QueryList<any>;
|
||||
@ViewChildren('foo') foos!: QueryList<any>;
|
||||
|
||||
showing = false;
|
||||
}
|
||||
@ -1658,7 +1653,7 @@ class SuperDirectiveQueryTarget {
|
||||
|
||||
@Directive({selector: '[super-directive]'})
|
||||
class SuperDirective {
|
||||
@ViewChildren(SuperDirectiveQueryTarget) headers !: QueryList<SuperDirectiveQueryTarget>;
|
||||
@ViewChildren(SuperDirectiveQueryTarget) headers!: QueryList<SuperDirectiveQueryTarget>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
Reference in New Issue
Block a user