0

Below this code console.log is working properly. How to set this data another page using another controller.

$scope.selectedJsonObject=function(category)
{
 console.log(category);
}
2
  • 2
    use a service to communicate between controllers Commented Jul 26, 2016 at 7:20
  • stackoverflow.com/questions/38563874/… This is my full question my friend. Commented Jul 26, 2016 at 7:39

1 Answer 1

0

You can use Service to share the variable across two controllers,

angular.module('Shared', []);
angular.module("Shared").factory("myService", function(){
  return {sharedObject: {data: "eran" } }
});
angular.module('Shared').controller('MainCtrl', function ($scope, myService) {
  $scope.myVar = myService.sharedObject;
});
angular.module('Shared').controller('Secondtrl', function($scope, $http, myService) {
  $scope.myVar = myService.sharedObject;
});

Working App

Sign up to request clarification or add additional context in comments.

2 Comments

@DRK apply the same on your app

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.