I've got an Angular 2 application with Typescript. I'm wondering how to access a child class from a parent class.
The parent class is like this:
@Component({
selector: 'all-data-page',
templateUrl: './all-data-page.component.html',
styles: [require('./all-data-page.style.scss')]
})
export class AllDataPageComponent implements OnInit {
...
}
Its selector looks like this:
<all-data-page [allData]="results.top3.Rows" type="Safeguards" *ngIf="!!results.AllDataSafeguards">
</all-data-page>
The child looks like this:
@Component({
selector: 'all-data-row',
templateUrl: './all-data-row.component.html',
styles: [ require('./all-data-row.style.scss') ],
encapsulation: ViewEncapsulation.None
})
export class AllDataRowComponent implements OnInit {
...
}
And its selector looks like this:
<div class="data-list">
<all-data-row *ngFor="let item of categoryRows; let last=last"
relativeWidth="100"
[item]="item.chartData"
[last]="last"
[ChartLabel]="item.chartData.ChartLabel"
[acmCat1]="item.chartData.acmCat1"
[acmCat2]="item.chartData.acmCat2"
[acmCat3]="item.chartData.acmCat3"
[acmCat4]="item.chartData.acmCat4"
[acmCat5]="item.chartData.acmCat5"
(click)="selectCategory(item.fullObject)"
[selected]="selected">
</all-data-row>
</div>
I would like to know how to reference the child class from the parent class.
Various sites that come up on google suggest using @ViewChildren but that doesn't work for me. The Chrome console just tells me "ViewChildren is not defined".
What must I do to get the parent class to access the child class?
Thanks.