2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-07-13 13:55:23 -04:00
|
|
|
import {Component, Directive, QueryList, ViewChild, ViewChildren} from '@angular/core';
|
2016-05-25 17:29:06 -04:00
|
|
|
|
|
|
|
@Component({selector: 'comp-for-child-query', template: 'child'})
|
|
|
|
export class CompForChildQuery {
|
|
|
|
}
|
|
|
|
|
2016-08-19 15:51:01 -04:00
|
|
|
@Component(
|
|
|
|
{selector: 'comp-with-child-query', template: '<comp-for-child-query></comp-for-child-query>'})
|
2016-05-25 17:29:06 -04:00
|
|
|
export class CompWithChildQuery {
|
2019-05-23 14:31:10 -04:00
|
|
|
@ViewChild(CompForChildQuery, {static: true}) child: CompForChildQuery;
|
2016-05-25 17:29:06 -04:00
|
|
|
@ViewChildren(CompForChildQuery) children: QueryList<CompForChildQuery>;
|
|
|
|
}
|
2016-07-13 13:55:23 -04:00
|
|
|
|
|
|
|
@Directive({selector: '[directive-for-query]'})
|
|
|
|
export class DirectiveForQuery {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'comp-with-directive-child',
|
|
|
|
template: `<div>
|
|
|
|
<div *ngFor="let data of divData" directive-for-query>{{data}}</div>
|
|
|
|
</div>`
|
|
|
|
})
|
|
|
|
export class CompWithDirectiveChild {
|
|
|
|
@ViewChildren(DirectiveForQuery) children: QueryList<DirectiveForQuery>;
|
|
|
|
|
|
|
|
divData: string[];
|
|
|
|
}
|