1

I have a dropdown list which is being used on several pages including the Home page. And I don't want to send data requests to the server for that drop-down list for all those pages. I want that drop-down list to be stored somewhere for all the pages at the time of loading the home page.

I could then use that several times on several pages without sending requests to the server each time. So that I could make my site a bit faster. Is there any way to do this?

Paulie-C
  • 1,674
  • 1
  • 13
  • 29
Hemant
  • 81
  • 9

1 Answers1

0

You can make use of Singleton Service, which can be referred by all the components in your application. Give the server request to fetch data at the start of application, and store the result in the form of properties or attributes declared within the Singleton Service.

Once you have the data within service, you can simply refer that instead of giving server request every time.

Refer here for Singleton Service : How do I create a singleton service in Angular 2?

Community
  • 1
  • 1
Amit Chigadani
  • 28,482
  • 13
  • 80
  • 98