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

290
Vistas
How to use component A functionalities in component B where both are independent?

I have component A with all functionalities and same needs to be used in component B. Since huge code is written in componentA.ts but not in service so in this case how can make use component A logic without using service where both are independent components.

I saw many post in stack overflow but could not find proper solution.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There is a few approaches to achieve your goal:

  1. Helper. If it's some complicated logic you can move it into shared helper class (something like 'shared/***.helper.ts)
  2. Inheritance. You can create parent component with all common logic and inherit it with 'extends' functionality. (You can read more about it here: https://www.bitovi.com/blog/4-reasons-to-fall-in-love-with-angular-component-inheritance) I personally don't think that this is the best practice for frontend, but in some particular cases it might be reasonable.
  3. Service. You said that you don't want to use service for that, but it's actually a valid architectural solution to use services not only for API interactions.
  4. Code duplication. If we are talking about some small functions which describe simple elements behaviour - it's okay to have small pieces of code duplication in different components.
about 4 years ago · Juan Pablo Isaza 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