Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!