4

I'm trying to pass multiple parameter in angular 2 router beta. But got error.

My app.route.ts file

export const routes : RouterConfig =[
    {path:'',component:DashboardComponent},
    {path:'login',component:LoginComponent},
    {path:'signup',component:SignupComponent},
    {path:'profile/:type/:name',component:ProfileComponent}
];

export const APP_ROUTER_PROViDERS = [
    provideRouter(routes)
];

dashboard.component.ts

export class DashboardComponent{
constructor(private router:Router){

}
profile():void{
    this.router.navigate(['/profile',{type:'artist',name:'mash'}]);
}}

profile.component.ts

export class ProfileComponent implements OnInit{
constructor(private route:ActivatedRoute,private router:Router){

}

type:string;
name:string;

ngOnInit(){
    console.log(this.route.snapshot.params);
}}

error enter image description here

What should I try now ? Please help. Thanks in advance.

1 Answer 1

3

For route params just use

this.router.navigate(['/profile','artist','mash']);

The array you added is for query parameters.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.