Angular2 : Call method/ngoninit when parameter of route changes
You have to subscribe to ActivatedRoute
service as follows :
//Component
import { Component, OnInit } from '@angular/core';import { ActivatedRoute, Params } from '@angular/router';export class YourComponent { constructor( private route: ActivatedRoute ) {} ngOnInit(): void { this.route.params.subscribe((params: Params) => { console.log(params); // this will be called every time route changes // so you can perform your functionality here }); }}