---
title: "How to pass value one page to another page using angularjs?"  
description: "How to pass value one page to another page using angularjs?"  
author: "Anonymous User"  
published: 2015-03-17  
updated: 2015-03-17  
canonical: https://www.mindstick.com/forum/23024/how-to-pass-value-one-page-to-another-page-using-angularjs  
category: "angular js"  
tags: ["angularjs service"]  
reading_time: 1 minute  

---

# How to pass value one page to another page using angularjs?

In the following [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) I’m [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to change to another [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) on [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) 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><script>        app.controller("ctrls",['$scope','$location',function($scope,$location){        $scope.func = function(i) {            $scope.var=i            $location.path("/rel");        };    }); app.controller("relctrls",'$scope',function($scope)   {    console.log($scope.var) //undefined});</script>
```

## Replies

### Reply by 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:

myService.set(yourSharedData);

In your controller B:

$scope.desiredLocation = myService.get();


---

Original Source: https://www.mindstick.com/forum/23024/how-to-pass-value-one-page-to-another-page-using-angularjs

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
