these are my controllers:
.controller('recommendedJobsCtrl', function($q,$scope, $ionicSideMenuDelegate,$window,$http,dataShare) {
$scope.text='hey world';
$scope.post=function(){
dataShare.sendData($scope.text);
console.log('sent: ' + $scope.text);
}
})
.controller('jobsCtrl', function($scope,dataShare) {
$scope.words=dataShare.getData();
})
and this is my factory:
.factory('dataShare',function($rootScope){
var service = {};
service.sendData = function(data){
service=data;
$rootScope.$broadcast('data_shared', service);
},
service.getData = function(){
console.log('this.data is ' + service)
return service;
};
return service;
});
when the console.log prints, service is empty. How do i fix this ?