Problem with switching links in Angular

Let's look at a solution to the problem with switching links in routing. This problem can be solved using the RxJS library, which is already included in Angular.

First, let's import the Subscription class:

app/aaaa/aaaa.component.tsimport { Subscription } from 'rxjs';

Let's make a private property:

app/aaaa/aaaa.component.tsexport class AaaaComponent { 
  private subscription: Subscription;
}

Let's create a property to store a parameter named id:

app/aaaa/aaaa.component.tsexport class AaaaComponent { 
  id: number | undefined;
  private subscription: Subscription;
}

Now let's subscribe to the change of the id parameter from the route:

app/aaaa/aaaa.component.tsexport class AaaaComponent { 
  id: number | undefined;
  private subscription: Subscription;
  
  constructor(private activateRoute: ActivatedRoute) {
    this.subscription = activateRoute.params.subscribe(params => this.id = params['id']);
  }
}
Задание 1

Fix the problem with switching links.