Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

634
Vistas
Angular error: NG0200: Circular dependency in DI detected

I am working on angular project where I have a service that gets the data from an API.

The service code:

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class CustomersService {

  constructor(public _HttpClient: HttpClient) { }

  getUsers(): Observable<any> {
    return this._HttpClient.get(`http://localhost:1234/labsystem/public/api/users`);
  }
}

And I am injecting the service in the component I need to view the users in it.

The component code:

import { Component, OnInit } from '@angular/core';
import { CustomersService } from 'src/app/customers.service';

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

  allUsers: any;

  constructor(public _CustomersService: CustomersService) {
    _CustomersService.getUsers().subscribe((data) => {
      this.allUsers = data;
    }, (error) => { console.log(error) });
  }

  ngOnInit(): void {
  }

}

The error in the browser console:

ERROR Error: NG0200: Circular dependency in DI detected for CustomersService. Find more at https://angular.io/errors/NG0200

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda