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

223
Vistas
Why are components not marked with @injectable annotation, but services need to be?

While defining a service / service class in angular, class is decorated with @injectable() decorator.

As per angular guidebook: @Injectable() marks a class as available to an injector for instantiation.

Then why it is not needed while creating a component?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

From the Angular documentation (emphasis mine):

Injectors are also responsible for instantiating components like HeroesComponent. So why doesn't HeroesComponent have @Injectable()?

You can add it if you really want to. It isn't necessary because the HeroesComponent is already marked with @Component, and this decorator class (like @Directive and @Pipe, which you learn about later) is a subtype of @Injectable(). It is in fact @Injectable() decorators that identify a class as a target for instantiation by an injector.

In other words, by marking a class as being a component, directive or pipe, you're implicitly marking them as injectable as well.

over 4 years ago · Santiago Trujillo Denunciar
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