如何在Angular应用中添加联系人组件

时间:2019-07-16 13:48:01

标签: angular

我已经用2个组件“ Home”和“关于”构建了网站,并且一切正常,但是如果我尝试以与“关于我的站点”组件相同的方式添加第三个组件,我会看到此消息从角度:Loading AppComponent content here ...

我想我的NG模块中有一些故障-我不确定thjis是否正确:

    import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';

import { AppComponent }  from './app.component';
import { headerComponent } from './header/app.headerComponent';
import { navComponent } from './nav/app.navComponent';
import { contentAreaComponent } from './contentArea/app.contentAreaComponent';
import { footerComponent } from './footer/app.footerComponent';
import { aboutComponent } from './About/app.aboutComponent';
import { contactComponent } from './contact/app.contactComponent';

@NgModule({
  imports: [ BrowserModule,
             RouterModule.forRoot([
    {
    path:'about',
    component:aboutComponent
    },
    {
    path:'contact',
    component:contactComponent
    },
    {
    path:'',
    component:contentAreaComponent
    }
        ])
      ],
      declarations: [ AppComponent ,
                      headerComponent,
                      navComponent,
                      contentAreaComponent,
                      footerComponent,
                      aboutComponent,
                      contactComponent
                  ],
      bootstrap:    [ AppComponent ]
})
export class AppModule { }

0 个答案:

没有答案