0

I have 2 components present in one ts file. TS: This is present in one component

addSubCategory(boat:Boat):void {
    const reff = this.dialog.open(AddSubCategoryDialog, {
      data: { }
    });
    const sub = reff.componentInstance.onBoatSubAdd.subscribe((data) => {
      this.boatSubTypes.boat_type_id = boat.id;
      this.service
          .addSubBoat(data)
          .subscribe(
            response => {
              console.log(response);
              this.dialog.closeAll();
              this.dialog.open(AddSubCategoryDialog);
              this.loadAllBoats();
            }, error => {
              this.snackBar.open('Failed to add company', 'X' , {
                duration: 2000,
              });
            });
   });
  }
}

I need to fetch the boat.id present in this file to the below given function This is present in one more component but within same TS file:

add(boatSubTypes:BoatSubTypes): void {
    this.addClicked = true;
    this.boatSubTypes.boat_type_id = this.boatSubTypes.boat_type_id;
    this.onBoatSubAdd.emit(boatSubTypes);
  }

Can anyone help me to solve this.

Bhrungarajni
  • 2,415
  • 11
  • 44
  • 88

0 Answers0