使用相對路徑這是我的文件夾結構:路由編程到其他組件中Angular2/4
App
-KitchenComponent
-css
-html
-kitchen.component.ts
-BedroomComponent
-css
-html
-kitchen.component.ts
app.component.html
app.component.ts
我想從廚房組件移到臥室組件編程方式使用相對路徑。
KitchenComponent.html
<button (click)="moveToBedroomComponent()"></button>
KithcenComponent.ts
Constructor(private router: Router){}
moveToBedroomComponent(){
this.router.navigate(['bedroom'], {relativeTo:_____});
}
我覺得我被困在給這裏的相對路徑,輸入讚賞。
嘿,有什麼不清楚[我的回答](https://stackoverflow.com/a/45453582/2545680)? –