Với góc 2, là nó cách nào để có đường tiểu không hiển thị vào thẻ chínhgóc 2: nhiều <Router-ổ cắm> cho các tuyến đường phụ
<router-outlet></router-outlet>
Ví dụ:
url : "http://mywebsite.com/"
MainComponent.ts
@Component({
...
template:'<router-outlet></router-outlet>'
...
})
@RouteCongif([
{path: '/products', name:'Product', component: Product}
])
Tùy chọn này hiển thị thành phần phụ vào bộ định tuyến < của bộ định tuyến > thẻ
Được rồi, giờ đây bạn có thể có loại cấu hình sau:
url : "http://mywebsite.com/products"
ProductComponent.ts
@Component({
template: `
...
<div> My list of products ! </div>
...
<a [RouteLink]="['ProductDetails', {slug-product-details:product.slug}]">
{{ product.name }} Details
</a>
...
<sub-router-outlet></sub-router-outlet>
`
})
@RouteConfig([
{path: '/:slug-product-details', name:'ProductDetails', component: ProductDetailsComponent},
])
Và
url : "http://mywebsite.com/products/one-product-details"
ProductDetailsComponent.ts
@Component({
...
template : `
<div> Details of the product : </div>
...
`
...
})
Tôi muốn giữ lại việc sử dụng các bộ định tuyến với ô tô được thiết kế url và diplay các tuyến đường và các chi tiết template vào loại này < sub-router-ổ cắm > thẻ.
Cảm ơn sự giúp đỡ của bạn.
Tôi có một mẫu bộ định tuyến lồng nhau nếu nó giúp: https://github.com/thelgevold/angular-2-samples/blob/master/app .ts và https://github.com/thelgevold/angular-2-samples/blob/master/demo-page.ts Có bản trình diễn tại đây: http://www.syntaxsuccess.com/angular-2-samples/ #/demo/graph – TGH
Nó có vẻ là những gì tôi đang tìm :) Cảm ơn bạn. –
Chỉ là một câu hỏi về bản demo. Liệu băm trong url không thể tránh khỏi? –