typescript - angular 2 Access child component object from parent component class -


need access property children element.

parent:

<div>    <shipment-detail #mycarousel ></shipment-detail> </div>  @component({   selector: "testproject",   templateurl: "app/partials/main.html") class appcomponent {    getchildrenproperty() {   // want access "shipment"    } } 

children:

@component({       selector: "shipment-detail",     })      export class shipmentdetail  {       shipment: shipment;     } 

the @viewchild , @viewchildren decorators provide access 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 name of child component class input , finds selector in parent component.

in case should shipmentdetail.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -