Ich baue eine Winkel 4-Anwendung. Ich bekomme einen Fehler
Error:Component HomeComponent is not part of any NgModule or the module has not been imported into your module.
Ich habe HomeModule und HomeComponent erstellt. Welches muss ich für das AppModule verwenden? Ich bin etwas verwirrt. Muss ich auf HomeModule oder HomeComponent verweisen? Letztendlich suche ich, wenn der Benutzer auf das Home-Menü klickt, sollte er zu der home.component.html geleitet werden, die auf der Indexseite gerendert wird.
App.module ist:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http'
import { AppComponent } from './app.component';
import { NavbarComponent } from './navbar/navbar.component';
import { TopbarComponent } from './topbar/topbar.component';
import { FooterbarComponent } from './footerbar/footerbar.component';
import { MRDBGlobalConstants } from './shared/mrdb.global.constants';
import { AppRoutingModule } from './app.routing';
import { HomeModule } from './Home/home.module';
@NgModule({
declarations: [
AppComponent,
FooterbarComponent,
TopbarComponent,
NavbarComponent
],
imports: [
BrowserModule,
HttpModule,
AppRoutingModule,
HomeModule
],
providers: [MRDBGlobalConstants],
bootstrap: [AppComponent]
})
export class AppModule { }
HomeModule ist:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HomeComponent } from './home.component';
@NgModule({
imports: [
CommonModule
],
exports: [HomeComponent],
declarations: [HomeComponent]
})
export class HomeModule { }
HomeComponent ist:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
HomeComponentzuentryComponents
@NgModule({ imports: [ CommonModule ], exports: [HomeComponent], declarations: [HomeComponent], entryComponents: [HomeComponent] })
