我在 angular2 中启动了一个项目,但无论出于何种原因,我的路线都会显示我的组件两次。这是相关的代码片段。
app.routing.ts
// Some import
import { AuthComponent } from './master/auth';
const appRoutes: Routes = [
{
path: 'master/registration',
component: AuthComponent
}
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
app.module.ts
import { AuthComponent } from './master/auth/auth.component';
import { AppComponent } from './app.component';
import { routing } from './app.routing';
@NgModule({
declarations: [
// components
AuthComponent
],
providers: [
// some providers
],
imports: [
BrowserModule,
ReactiveFormsModule,
routing
],
bootstrap: [AppComponent]
})
export class AppModule {}
app.component.html包含<app-auth></app-auth>
auth.component.ts
import { Component, OnInit } from '@angular/core';
import * as all from './auth-utils';
@Component({
moduleId: module.id,
selector: 'app-auth',
templateUrl: 'auth.component.html',
styleUrls: ['auth.component.css']
})
export class AuthComponent implements OnInit {
constructor() {}
ngOnInit() {
}
}
auth.component.html
<app-register-form [fields]="fields"></app-register-form>
<app-login-form [loginFields]="loginFields"></app-login-form>
<router-outlet></router-outlet>
我在这里想念什么?