2017-08-30 159 views
0

我目前正在使用Angular 4開展一個項目。直到今天,我沒有使用路由器的問題,但我使用了Angular Materials組件,今天早上我看到我必須更新Angular Material軟件包。我執行:Angular 4路由器加載所有組件

npm update 

從那時起,當我使用RouterLink,組件加載實際頁面頂部。例如,如果我在'/ dashboard'中,並且想要轉到'/ signin'頁面。 「登錄」組件加載在儀表板的頂部,因此在同一頁面中,我有儀表板組件登錄組件。

你有想法幫我解決這個問題嗎?

編輯:

我的部件沒有更多的responsives,如果我用一個* ngFor在我的組件定義了一個數組,如果數組改變與* ngFor不改變組件...我認爲,我所有的問題都有聯繫,但我看不出如何。

我如何使用RouterLink:

<a md-tab-link routerLink="/login" routerLinkActive="active">Login</a> 

我app.routing.module.ts的代碼:

import { NgModule }    from '@angular/core'; 
import { RouterModule, Routes } from '@angular/router'; 
import { SentierDetailComponent } from './map/sentier/sentier-detail.component' 
import { DashboardComponent } from './dashboard/dashboard.component'; 
import { LoginComponent } from './login/login.component'; 
import { SignInComponent } from './signin/signin.component'; 
import { MembreComponent } from './membre/membre.component' 
import { FormComponent } from './form.component' 

const routes: Routes = [ 
    { path: '', redirectTo: '/dashboard', pathMatch: 'full' }, 
    { path: 'dashboard', component: DashboardComponent }, 
    { path: 'login', component: LoginComponent}, 
    { path: 'signin', component: SignInComponent}, 
    { path: 'sentier-detail/:id', component: SentierDetailComponent}, 
    { path: 'membres', component: MembreComponent}, 
    { path:'evenement', component: FormComponent} 
]; 

@NgModule({ 
    imports: [ RouterModule.forRoot(routes) ], 
    exports: [ RouterModule ] 
}) 
export class AppRoutingModule {} 
+0

請提供有關如何使用'RouterLink'的更多信息(代碼示例) –

+0

請提供如何配置RouterModule –

回答

0

嗯,這似乎錯誤是從文件app.module未來.TS。我從我的項目的舊版本中取出了它的舊版本,現在一切正常,但我仍然不確切知道此錯誤的來源。

相關問題