1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

I am new in Angular 2. I have tried to create a component but I got this error

Discussão em 'Angular' iniciado por yehoudi, Outubro 17, 2024 às 19:22.

  1. yehoudi

    yehoudi Guest

    Here's my app.component.ts file :

    import { Component } from '@angular/core';

    @Component({
    selector: 'app-root',
    standalone: false,
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
    })
    export class AppComponent {
    title = 'frontend';
    }



    My ProjectListComponent file

    import { Component, OnInit } from '@angular/core';
    import { ProjectService } from '../../services/project.service';
    import { Project } from '../../models/Project';

    @Component({
    selector: 'app-project-list',
    templateUrl: './project-list.component.html',
    styleUrls: ['./project-list.component.scss']
    })
    export class ProjectListComponent implements OnInit {

    projects: Project[] = [];

    constructor(private projectService: ProjectService) { }

    ngOnInit(): void {
    this.projectService.getProjects().subscribe(data => {
    this.projects = data;
    });
    }

    }



    The app.module.ts file

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { AppComponent } from './app.component';
    import { ProjectListModule } from './components/project-list/project-list.module';

    @NgModule({
    declarations: [
    AppComponent
    ],
    imports: [
    BrowserModule,
    ProjectListModule
    ],
    providers: [],
    bootstrap: [AppComponent]
    })
    export class AppModule { }



    And the angular component I try to use in my app.component.html : <app-project-list />

    The errors :

    1. If app-project-list is an Angular component, then verify that it is part of this module.
    2. If app-project-list is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

    PLEASE HELP !

    Continue reading...

Compartilhe esta Página