Buduję aplikację kątową 4. Pojawia się błąd Komponent HomeComponent nie jest częścią jakiegokolwiek modułu NgModule lub moduł nie został zaimportowany do modułu. Stworzyłem HomeModule i HomeComponent. Którego potrzebuję odnieść w AppModule. Jestem trochę zdezorientowany. Czy muszę odwołać HomeModule lub HomeComponent. Ostatecznie szukam, gdy użytkownik kliknie menu główne, powinien zostać przekierowany do pliku home.component.html, który zostanie wyrenderowany na stronie indeksu.Komponent nie jest częścią jakiegokolwiek modułu NgModule lub moduł nie został zaimportowany do modułu
App.module
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
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
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() {
}
}
czy używasz leniwego ładowania? –
Tak. Jak to zrobić z leniwym ładowaniem – Tom
dodać 'HomeComponent' do' entryComponents' –