Supriya Rapelli
Supriya Rapelli

Reputation: 93

Send form data from one page to another page using angularjs

Hello can any one please tell me how to send on form data to another by clicking submit button using angular JS.

Upvotes: 0

Views: 646

Answers (1)

binariedMe
binariedMe

Reputation: 4329

There are three ways to do that.

  1. If you are using SPA flow for your website, you can make a service for data that are to be shared among pages. Redirection will only change the hash value of URL and landing page will still have those data from service.
  2. Second is to use the hash value for data as lets say that you are redirecting from baseURL/test1 to baseURL/test2 so instead of redirecting to baseURL/test2, you can redirect to baseURL/test2#/data=* , * representing the data. The redirection will still happen but now you can also get the data.
  3. Third is to use local storage or webSQL ( although limited browser support for webSQL), to save the data and then retrieve back on the next page.

While I will stick to the SPA flow for my angular website and use a service to pass on the data. There is also a way to assign data in $rootScope but that is just not a good practice to pass on data from one page to another.

Upvotes: 4

Related Questions