2016-07-18 3 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

관련 문제