user18928007
user18928007

Reputation:

VS Code can not found Angular component in *.HTML

All my component in Angular frontend is undefined with message

(element) XXXXX: HTMLElement
'XXXX' is not a known element:
1. If 'XXXX' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.ngtsc(-998001)

Undefined component

in other case component defined correctly

@Component({
    selector: 'grid',
    templateUrl: './grid.component.html',
    styles: [`
        .vacation_today {
        background-color: #b6afaf;
    }
    `]
})
export class GridComponent implements OnChanges, OnInit {

and in runtime frontend working correctly.

Any my attempt to add additional definition to *.ts like

import { GridComponent } from './../../../../components/grid/grid.module';

was unsuccessful. And all my code marked as red on the right panel. How to fix this error message?

Upvotes: 0

Views: 563

Answers (1)

Lonli-Lokli
Lonli-Lokli

Reputation: 3786

All the angular components should be either standalone (Ng 14.2+) or part.of NgModules. On both case feature component, which using you grid component in html template, must mention grid,s NgModule (or grid itself if it's standalone) in the imports section

@Component({
imports: [
GridModule,
...

Or

@NgModule({
imports: [
GridModule,
...

Upvotes: 0

Related Questions