2017-02-22 5 views
1

特定のコンポーネントを表示するURLでアプリケーションをリロードすると、代わりにデフォルトのページが表示されるという問題があります。たとえば、ブラウザ上で/ create/userに直接行きたいのですが(リフレッシュ)、私のデフォルトページを表示します。ルータはリフレッシュ後にコンポーネントにルーティングされません。

ここは私のルート設定です。その後、

import {provideRouter, RouterConfig} from '@angular/router'; 
import {GenericRequestEndpoint} from './components/dynamicresponsetable/dynamicresponsetable.component'; 
import {DynamicDisplayForm} from './components/dynamicdisplaycomponent/dynamic.display.component'; 
import {DynamicCreationComponent} from './components/dynamiccreationcomponent/dynamic.creation.component'; 
import {LoginComponent} from './components/login/login.component'; 
import {AuthService} from './components/services/auth.service'; 
import {AuthGuard} from './components/services/auth-guard.service'; 
import {Dummy} from './components/dummy'; 
import {ConfigurationComponent} from './components/configurationcomponent/configuration.component'; 


export const ROUTER: RouterConfig = [ 
    { 
     path: '', 
     component: LoginComponent 
    }, 
    { 
     path: 'dashboard', 
     component: Dummy, 
     canActivate: [AuthGuard] 
    }, 
    { 
     path: 'endpoint/:endpointname', 
     component: GenericRequestEndpoint, 
     canActivate: [AuthGuard] 
    }, 
    { 
     path: 'detail/:specificitem', 
     component: DynamicDisplayForm, 
     canActivate: [AuthGuard] 
    }, 
    { 
     path: 'create/:endpointname', 
     component: DynamicCreationComponent, 
     canActivate: [AuthGuard] 
    }, 
    { 
     path: 'configurator/:endpointname', 
     component: ConfigurationComponent, 
     canActivate: [AuthGuard] 
    } 
]; 



export const APP_ROUTER_PROVIDERS = [ 
    provideRouter(ROUTER), AuthService, AuthGuard 
]; 

答えて

1

あなたは子供のルートなしで、空のパス''を使用している場合、それは動作しませんでしたpathMatch

{ 
    path: '', 
    component: LoginComponent, 
    pathMatch: 'full' 
}, 
+0

を追加します。たぶん私は良い例を挙げなければならないかもしれません。ユーザーが別のユーザーにリンクを送信したとします。たとえば、http:// localhost:3000/create/userです。私の問題は、AngularがDynamicCreationComponentにリダイレクトしていないことです。ルータはただ空です。 –

+0

あなたはどのサーバーを使用していますか?これは 'ng serve'で起こっていますか? –

+0

"ルータはただ空です"とどういう意味ですか? –

関連する問題