How to pass data from component to another on angular 7 ?
I work on angular 7 i need when click button transfer data from current component to another component
displayreportservice.ts
- GetSpByRevisionId(datarevision : any){
- return this.http.post<any>('http://localhost:61265/api/report',datarevision)
-
- }
currentcomponent.html
- <td> <button (click)="getDataByRevision(rep[0])">Download</button> </td>
currentcomponent.ts
- ReportData:any={};
- getDataByRevision(RevId : any)
- {
- console.log("REVEISIONID IS " + RevId);
- console.log(this.ReportData);
- this.ReportData.forEach(function(e) { e.revisionID=RevId });
- this._displayreport.GetSpByRevisionId(this.ReportData).subscribe(async data=>{
- console.log(data)
- await this.exportJsonAsExcelFile(data ,'datarevision');
- });
-
-
- }
How to transfer data from component above to target component when click button :
targetcomponent.ts
- export class ReportCategoryComponent implements OnInit {
-
- datalis:string;
- reportlist:any[];
- subreportlist:any[];
- searchData:any={};
- constructor(public http: HttpClient, private _router: Router, private _displayreport: DisplayreportService) { }
-
- ngOnInit() {
- //here i need to get data of getdatabyrevisionfunction
- //meaning i need to get result of
- this.exportJsonAsExcelFile(data ,'datarevision'); here
- }
- }
How to transfer data from current component.ts to target component.ts