Angular 4路由器加载所有组件

时间:2017-08-30 15:05:34

标签: angular router routerlink angular4-router routerlinkactive

我目前正在开发一个使用Angular 4的项目。直到今天我对Router没有任何问题,但我使用Angular Materials组件,今天早上我看到我必须更新Angular Material包。我执行了:

npm update

从那时起,当我使用RouterLink时,组件将加载到实际页面之上。例如,如果我在'/ dashboard',我想转到'/ signin'页面。 'signin'组件加载在仪表板的顶部,因此在同一页面中我有仪表板组件 signin组件。

您有什么想法帮我解决这个问题吗?

编辑:

我的组件不再响应,如果我使用* 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 {}

1 个答案:

答案 0 :(得分:0)

好吧,似乎错误来自app.module.ts文件。我从我的项目的旧版本中获取了旧版本,现在一切都很好,但我仍然不确切知道这个bug的来源。

相关问题