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
( 'http://localhost:61265/api/report',datarevision) - }
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');
- });
- //console.log(this.reportdetailslist);
- }
targetcomponent.ts
- export class ReportCategoryComponent implements OnInit {
- //reportlist:report[];
- 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
- }
- }
Rajanikant HawaldarPosted May 10, 2020, 4:07 AM