Skip to content

Instantly share code, notes, and snippets.

@lighth7015
Last active November 19, 2021 02:04
Show Gist options
  • Save lighth7015/c69c302412fa4596f3cac821ae055476 to your computer and use it in GitHub Desktop.
Save lighth7015/c69c302412fa4596f3cac821ae055476 to your computer and use it in GitHub Desktop.

Angular compile message(s):

Error: src/app/app.component.html:74:2 - error NG8001: 'app-page' is not a known element:
1. If 'app-page' is an Angular component, then verify that it is part of this module.
2. If 'app-page' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

74  <app-page></app-page>
    ~~~~~~~~~~

  src/app/app.component.ts:7:15
    7  templateUrl: './app.component.html',
                    ~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component AppComponent.
<main>
<app-page></app-page>
</main>
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
providers: [NgbModalConfig, NgbModal]
})
export class AppComponent {
title = 'test';
closeResult = '';
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { PageModule } from './page/page.module';
import { AppComponent } from './app.component';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { RouterModule } from '@angular/router';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule.withServerTransition({ appId: 'serverApp' }),
PageModule,
NgbModule,
AppRoutingModule,
RouterModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
<p>page works!</p>
// src/app/page/page.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-page',
templateUrl: './page.component.html',
})
export class PageComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
// src/app/page/page.component.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PageComponent } from './page.component';
@NgModule({
declarations: [
PageComponent
],
imports: [
CommonModule,
]
})
export class PageModule { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment