Components and Services

Asked

Viewed 22 times

0

I am developing an application and came across the following problem:

I am working with an api that manages a website and have some endpoints like: banners, testimonials, user, images etc, most endpoints have some relationship with images, so I decided to create an endpoint images to center uploads, all images are uploaded to this endpoint images where the necessary validations are made.

when I am going to do some registration that needs images, I first do the image registration at endpoint images that returns me an array with the registry ids of the database where I store the directories, the site is angled, created a component fileinput to receive the images, this component has a serviceA that connects with the api in endpoit images, my doubt falls here: after the image is sent to the server and me returned the ids; who has access is the serviceA of fileinput, but I complete the register with the componentB who uses the serviceB how can I do to bring the return of serviceA into the serviceB?

  • @Injectable... Inject serviceA into serviceB

1 answer

1


You can inject one service into another.

In your A service create a method that returns what you want:

@Injectable()
export class valores {
 checValues(){
    return this.values;}}

This method will be injected into service B as follows:

constructor(
    private valueService: valores) { }

And to call the method:

this.valueService.checkValues();

If you have questions, see the video below:

https://www.youtube.com/watch?v=hMhCDO75Aus&list=PLGxZ4Rq3BOBoSRcKWEdQACbUCNWLczg2G&index=43

Browser other questions tagged

You are not signed in. Login or sign up in order to post.