-1

I want to send the data when im navigating to page . How can i see the data in second page.

Example.

    this.router.navigate(['/dashboard/home', {company_id: '659'}]);

I m passing company_id to homeComponent. how can i console Company_id in homecomponent Thanks

Umaiz Khan
  • 1,319
  • 3
  • 20
  • 66
  • 2
    Possible duplicate of [How to pass data between two components in Angular 2](https://stackoverflow.com/questions/39325503/how-to-pass-data-between-two-components-in-angular-2) – Yug Singh May 08 '19 at 08:32

1 Answers1

1

Firstly,set your homeComponent constructor

constructor(
    private activatedRoute: ActivatedRoute
    .....
) { }

and get params on ngOnInit function

ngOnInit(){
 this.activatedRoute.params.subscribe(
    params=> {
           const company_id = params['company_id'];
           console.log(company_id);
});
ahmeticat
  • 1,899
  • 1
  • 13
  • 28