2016-07-18 5 views
3

Я пытаюсь передать несколько параметров в бета-версии 2-го маршрутизатора. Но появилась ошибка.Как обрабатывать несколько параметров в угловой бета-версии маршрутизатора 2?

Мой app.route.ts файл

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); 
}} 

ошибка enter image description here

Что я должен сейчас попробую? Пожалуйста помоги. Заранее спасибо.

ответ

2

Для маршрута PARAMS просто использовать

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

Добавленная массив параметров запроса.

+0

Спасибо. Оно работает :) – Shuvo

Смежные вопросы