abrahamlinkedin
abrahamlinkedin

Reputation: 467

How to generate user profile route with Angular2 + Firebase

I am having trouble finding resources that might explain how to develop a custom user page route. Something like a www.website.com/user/uid, where uid represents the user's ID set by Firebase.

So for a sample like:

const APP_ROUTES: Routes = [
    { path: '', component: HomeComponent },
    { path: 'profile', component: ProfileComponent }
]; 

How might I create a user profile page and its route?

Any insights and/or resources would be greatly appreciated.

Upvotes: 1

Views: 542

Answers (1)

williamsandonz
williamsandonz

Reputation: 16430

const APP_ROUTES: Routes = [
    { path: '', component: HomeComponent },
    { path: 'profile/:id', component: ProfileComponent }
]; 

Then in your ProfileComponent

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

and your constructor:

constructor(private _activatedRoute: ActivatedRoute) {
  _activatedRoute.params.subscribe(params => {
    this.id = parseInt(params['id']);
  });
}

Upvotes: 1

Related Questions