import { Component, ViewChildren, ContentChild, QueryList, Input } from '@angular/core'; @Component({ selector: 'active-label', template: ` Active ` }) class ActiveLabelComponent { active:boolean; activate() { this.active = true; } } // #docregion content @Component({ selector: 'hero', template: `

{{hero.name}}

` }) class HeroComponent { @Input() hero:any; active:boolean; @ContentChild(ActiveLabelComponent) label:ActiveLabelComponent activate() { this.active = true; this.label.activate(); } } // #enddocregion content // #docregion view @Component({ selector: 'heroes-queries', template: ` `, directives: [ HeroComponent, ActiveLabelComponent ] }) export class HeroesQueriesComponent { heroData = [ {id: 1, name: 'Windstorm'}, {id: 2, name: 'Superman'} ]; @ViewChildren(HeroComponent) heroCmps:QueryList; activate() { this.heroCmps.forEach( (cmp) => cmp.activate() ); } } // #enddocregion view