Components and Services

0

I'm developing an application and I came across the following problem:

I'm working with an api that manages a website and I have some endpoints like: banners , testimonials , user / strong> etc, most endpoints have some relation to images , so I decided to create a images endpoint to centralize uploads, all images are sent to this endpoint images where the necessary validations are done.

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

asked by anonymous 19.07.2018 / 15:55

1 answer

1

You can inject one service into another.

At your service A 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 any questions, check out the video below:

    

19.07.2018 / 16:07