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

angular - DownloadURL return null in below code -

meteor - inserting data to database gives error "insert failed: Method '/texts/insert' not found" -