Routing Angular Applications

Route Parameters

To get route parameters, we'll be using something called the ActivatedRoute from the @angular/router.

Once we have the ActivatedRoute, we can grab params using:

import { ActivatedRoute } from '@angular/router';

...

export class AboutUserComponent implements OnInit {
  user;

  constructor(private route: ActivatedRoute) {}

  ngOnInit() {
    // grab the current username
    let username = this.route.snapshot.params['username'];

    this.user = users.find(function(user) {
      return user.username === username;
    });
  }

}