Home > DeveloperSection > Forums > How to pass value one page to another page using angularjs?
Pravesh Singh
Pravesh Singh

Total Post:101

Posted on    March-17-2015 7:17 AM

 Angular JS Angularjs Service 

 1 Reply(s)
 11645  View(s)
Rate this:

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



Ankita Pandey
Ankita Pandey

Total Post:183

Posted on    March-17-2015 7:22 AM

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();

Don't want to miss updates? Please click the below button!

Follow MindStick