Routing Angular Applications: Lesson 9 of 23

Route Parameters

Up Next

Refactoring for User Service

Autoplaying in 7 seconds!



Table of Contents

    o 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 {
      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;

    Chris Sevilleja

    176 posts

    Founder of Google Developer Expert in Web Technologies. Slapping the keyboard until something good happens.