0

I'm trying to pass a json object just after redirecting to another page, The problem is when I use $scope.data in order to save client, the problem is that after making the redirection the $scope.data is empty again

testProjectApp.controller('ClientController', 
 function EventController($scope, clientList, $window, updateClient){


    $scope.editClient=function(client){
        $scope.data=client;
        $window.location.href = 'ClientDetails.html";
    }

the controller is working on two pages

avi
  • 29
  • 2
  • http://stackoverflow.com/questions/25647454/how-to-pass-parameters-using-ui-sref-in-ui-router-to-controller – Bleja_ Nov 10 '15 at 16:18

2 Answers2

0

It depends on if you only want to use angular specific APIs or general methods are also acceptable. Consider the followings, which one better fits your situation, you may need to serialize/de-serialize the json object:

Some options:

  1. Cookies
  2. Session Storage
  3. Local Storage
  4. Use Url to pass the parameters
  5. If it is a single page application, then you can just set it to a variable in a Service, and inject that service the controllers need the var. Basically a get, set

It would be a good idea to figure out the size of the json, and are there any limits and constraints first, then choose the suitable method.

LYu
  • 2,316
  • 4
  • 21
  • 38
0

Angular is used for SPA's - single paged applications. As soon as you redirect to another page, a new scope is created. I used local storage - here I asked and answered my question in reference to it - AngularJS help sharing data between controllers using $broadcast

So to be honest, this is a duplicate.

Community
  • 1
  • 1
notAChance
  • 1,360
  • 4
  • 15
  • 47