Reputation: 691
Need to access to property children element.
Parent:
<div>
<shipment-detail #myCarousel ></shipment-detail>
</div>
@Component({
selector: "testProject",
templateUrl: "app/partials/Main.html")
class AppComponent {
getChildrenProperty() {
// I want to get access to "shipment"
}
}
Children:
@Component({
selector: "shipment-detail",
})
export class ShipmentDetail {
shipment: Shipment;
}
Upvotes: 3
Views: 2240
Reputation: 15292
The @ViewChild
and @ViewChildren
decorators provide access to the class of child component:
@Component({
selector: "testProject",
templateUrl: "app/partials/Main.html")
class AppComponent {
@ViewChild(ShipmentDetail) ShipDetails: ShipmentDetail;
getChildrenProperty() {
console.log(this.ShipDetails.shipment);
}
}
@ViewChild
requires the name of child component class as its input and finds its selector in the parent component.
In your case it should be ShipmentDetail
.
Upvotes: 4