title: Angular 4 Component ngOnInit not called on each route request
body: <p>I just recently started diving into Angular 4 coming from Angular 1.5.  I'm working with user routes and pulling API data from a service into a user component. </p>
  
  <p>The component seems to stay static unlike controllers in 1.* where they were refreshed on each request.</p>
  
  <p>Is there anyway to have the ngOnInit function called on each new route request?</p>
  
  <p>My user component class:</p>
  
  <pre><code>// url structure: /user/:id
  export class UserComponent implements OnInit {
  
      constructor(private route: ActivatedRoute) {}
  
      ngOnInit() {
  
        // doesn't log new id on route change
        let id = this.route.snapshot.params['id'];
        console.log(id);
  
        this.route.params
          .switchMap(params =&gt; this.userService.getUser(params['id']))
          .subscribe(user =&gt; {
            // logs new id on route change
            let id = this.route.snapshot.params['id'];
            console.log(id);
  
            this.user = user
          });
      }
  }
  </code></pre>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>Found a solution that I think works best for my scenario.  Based on several answers and comments to my question and further investigation, subscribing to the route seems to be the way to go.  Here is my updated component:</p>
  
  <pre><code>export class UserComponent {
  
    user;
    id;
  
    constructor(
      private userService: UserService,
      private route: ActivatedRoute
    ) {}
  
  
    ngOnInit() {
      this.route.params
        .subscribe(params =&gt; this.handleRouteChange(params));
    }
  
    handleRouteChange(params) {
      this.id = params['id'];
  
      switch (this.id) {
        case '1':
          console.log('User 1');
          break;
  
         case '2':
          console.log('User 2');
          break;
  
         case '3':
          console.log('User 3');
          break;
      }
  
      this.userService.getUser(this.id).
        subscribe(user =&gt; this.user = user);
    }
  
  }
  </code></pre>