How to pass value one page to another page using angularjs?

In the following code I’m trying to change to another page on click and want to pass the object. How can I do it. In the following code I get it as undefined how to go about this

<a href="#/rel" ng-click="func(i)">{{i.display}}</a>
        $scope.func = function(i) {
app.controller("relctrls",'$scope',function($scope)   {
    console.log($scope.var) //undefined

Last updated:3/17/2015 7:22:09 AM

1 Answers

Anonymous User
Anonymous User

Pages normally have controller(s), a service can be created to share data between pages ( by injecting service in associated controllers). Like: 

app.factory('myService', function() {
 var savedData = {}
 function set(data) {
   savedData = data;
 function get() {
  return savedData;
 return {
  set: set,
  get: get

In your controller A: 


In your controller B: 

$scope.desiredLocation = myService.get();