私はAngular2を使ってルータで作業しています。私が作りたいURLは 'https://mail.google.com/mail/u/0/#search/angular/15y58930e5a82911'です。このURLは、メールボックスで「Angular」を検索し、検索結果から特定のメールを選択すると表示されます。しかし、私のアプリケーションはそれを達成できません。Angular2ルータを使用してURLのようにGmailを作成するにはどうすればよいですか?
私のアプリケーション構造はこのようなもので、私はAppModuleとSearchModuleを持っています。 各モジュールには独自のルータがあります。
app.routes.ts
export const routes: Routes = [
{
path: '',
loadChildren: './home/index#HomeModule'
},
{
path: 'search',
loadChildren: './search/index#SearchModule'
}
];
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: `
<app-header></app-header>
<router-outlet></router-outlet>
`
})
export class AppComponent {
}
search.routes.ts
export const SearchRoutes = [
{
path: 'search',
component: SearchContainerComponent,
children: [
{ path: '', redirectTo: 'intro', pathMatch: 'full' },
{ path: 'intro', component: SearchIntroComponent },
{ path: 'artist/:id', component: DetailViewComponent }
]
},
];
search.container.component
@Component({
selector: 'app-search-container',
template: `
<div class="container">
<div class="col-md-5">
<app-search (search)="searchArtist($event);"> </app-search>
<artist-list
[artistList]="artistsList"
(artist)="displaySelectedArtist($event)"
></artist-list>
</div>
<div class="col-md-7">
<router-outlet></router-outlet>
</div>
</div>
`
})
export class SearchContainerComponent implements OnInit {
}
これらのコードでは、左側のパネルに、検索の結果としてアーティストのリストが表示されるはずです。右のパネルで、最初のアーティストの詳細情報が自動的に表示されるはずです。対応するURLはhttp://xxx.xxx.com/#/artist/11になります。 11は、コーヒーを使ってアーティストを検索した最初のアーティストです。しかし、私が望むURLはhttp://xxx.xxx.com/#/artist/11の代わりにhttp://xxx.xxx.com/#/search/coffee/artist/11 'です。
あなたの誰かがこれについていくつかアドバイスしていただけますか?
の詳細については、このリンクを行くはい、私は原則を知って、あなたが示した道をしましたが、私は期待どおりに動作しませんでした。したがって、すでにルートルーターに定義されていても、「検索」を追加することになります。とにかく、私はそれをさらに調べて、それを理解しようとしています。私はPluralsightであなたの講義を見てきました:) –