I tried sharing data between two controllers using a factory. For some reason, the two inputs don't share data. In the AppCtrl controller I assign Data.FirstName to equal lattitude. But when I get to the PathController, I can't read the value stored in Data.FirstName.
Can anyone let me know what is wrong with my code?
.factory('Data', function(){ return { FirstName: 'jjjj' }; }) // controller one .controller('AppCtrl', function($scope, Data, $http, $ionicModal, $timeout) { .... $scope.mapLocation = function(lattitude, longittude) { Data.FirstName = lattitude; $scope.Data = Data; } .... }) // controller two .controller("PathController", [ '$scope', function($scope, Data) { $scope.Data = Data; console.log(Data.FirstName); // Not getting Data.FirstName angular.extend($scope, { center: { lat: 35.720031000963, lng: -87.343068987131, zoom: 17 }, markers: { Campus: { lat: 35.728031000963, lng: -87.343068987131, focus: true, draggable: false, message: "Building1" }, }, defaults: { scrollWheelZoom: false } }); }])