0

I want to have slightly different content on a page or just different data lists, depending on what the user clicked on the previous page. So if I have two buttons: Friends and Nearby. I want to have the same page in both options, but different data. Like Option 1: The Friends Data and Option 2: The Data nearby. I don't want to make an additional page for every option since the html content would be almost the same. I actually have no idea of how to do it. But I have put below some code of how I imagined the logic, since I want to control it with bools.

 if (route === friends.clicked) {
    this.friends = true;
  }
  if (route === nearby.clicked) {
    this.nearby = true;
  }
Colin Ragnarök
  • 1,062
  • 9
  • 18
  • Maybe you should look at option route parameters https://angular-2-training-book.rangle.io/routing/query_params – Saksham Sep 21 '19 at 18:58

1 Answers1

0

You can use route params to pass the data in the URL from the previous page (component) this this page. And in the page or in the ngOnInit() of this page component you can read the route params and show the appropriate template.

Read about the route params here in the angular docs.

You can also refer to this answer.

Nithin Kumar Biliya
  • 2,763
  • 3
  • 34
  • 54