Angular 2 route with parameters re-initializing component onInit

前端 未结 2 1287
醉梦人生
醉梦人生 2021-01-18 12:45

I have an issue where my component is re-initializing when I route to it with new parameters. Here are my routes.

const appRoutes: Routes = [
  { path: \'\'         


        
2条回答
  •  离开以前
    2021-01-18 13:42

    I used a different approach, listening to the Activated route in my Component

    import { ActivatedRoute } from '@angular/router';
    
    constructor(
    private route: ActivatedRoute
    ) {
      this.route.url.subscribe(url =>{
          /* Your function*/
      });
    }
    

提交回复
热议问题