Tôi đang xây dựng một ứng dụng 4 góc. Tôi đang gặp lỗi
Error:Component HomeComponent is not part of any NgModule or the module has not been imported into your module.
Tôi đã tạo HomeModule và HomeComponent. Tôi cần tham khảo cái nào trong AppModule? Tôi la một chut Nhâm lân. Tôi có cần tham khảo HomeModule hoặc HomeComponent không? Cuối cùng những gì tôi đang tìm kiếm là khi người dùng nhấp vào menu Trang chủ, họ sẽ được chuyển hướng đến home.component.html sẽ được hiển thị trên trang chỉ mục.
App.module là:
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 là:
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 là:
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() {
}
}