Dynamically pass http params from form to service provider

I have a form that users select options from and then I need to use those selections to send http get or put requests. How can I pass this data to URLSearchParams in my service provider?.. Initially, I was thinking I could use nav params, but found out that’s not allowed by design. Appreciate any help on how to accomplish this.

Presumably you are making some sort of function call on the service provider, like:

widgetsByClass(widgetClass: string): Observable<Widget> {}

You can just pass whatever is appropriate like widgetClass here.

I guess I’m doing this the wrong way. I have a main page or page 1 that is used for the data input. Then when you click submit it pushes a list page or page 2 … depending on selection it will push another page. The list or page 2 doesn’t have access to the required parameters. So, I guess I should be passing them from page 1 before pushing page 2? I’ve been testing with hard coded values for the GET requests because have been working through other problems. Does that sound correct to you?..

Give the data to the provider before pushing the page. setData(data: Datatype), getData(): Datatype, that sort of thing.

1 Like

Hi Aaron,
Sorry, I’m not understanding how to push the data to the provider … Would you be able to provide a plunker or some additional information on how to do this?

Please read the official Angular docs on service providers. There are multiple code examples there.

Hi George,

Did you get answer for this problem ? if so , please share with me . I am also in like situation.

Thanks

Anes