I am getting a simple parameter via the router, using Angular2 RC5. The 
parameter is just a name. In app.routes.ts, I set the route parameter to 
"directory/:ninja".

*app.routes.ts*
import { Routes, RouterModule } from "@angular/router";
import { DirectoryComponent } from "./directory/directory.component";
import { HomeComponent } from "./home/home.component";

const APP_ROUTES: Routes = [

{ path: 'directory/:ninja', component: DirectoryComponent },
{ path: '', component: HomeComponent }

];

export const APP_ROUTES_PROVIDER = RouterModule.forRoot(APP_ROUTES);

*directory.component.ts*
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-directory',
  templateUrl: './directory.component.html',
  styleUrls: ['./directory.component.css']
})
export class DirectoryComponent implements OnInit {

  ninja: string;    

  constructor(public route: ActivatedRoute) { 

    this.ninja = route.snapshot.params['ninja'];

  }

  ngOnInit() {
  }

}

*directory.component.html*
{{ninja}}

Whenever I access http://localhost:4200/directory/richard, it redirects me 
to the ROOT URL. Richard is the name of the ninja.

It should display the name of the ninja in directory.component.ts


Please help

-- 
You received this message because you are subscribed to the Google Groups 
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to