AngularJS 1.4

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://cdn.rawgit.com/angular-ui/bootstrap-bower/0.13.4/ui-bootstrap-tpls.js"></script>
<div ng-app="SharingDataBetweenControllers" ng-scope>
    <div ng-controller="Controller5a">
    first controller:<input ng-model="text" ng-change='set()'/>
    </div>
    <div ng-controller="Controller5b">
    second controller: {{Share.get()}}
    </div>
</div>

JavaScript

var module = angular.module('SharingDataBetweenControllers', []);

module.factory('Share', function(){
     var text ='hello';
    return { 
      get: function(){
          return text;
      },
			set: function(value){
      	
      	text=value;
        console.log(text);
      }
    };
});

module.controller('Controller5a',function($scope, Share) {
Share.set("updated value");
  $scope.text = Share.get();
});

module.controller('Controller5b', function($scope, Share) {
	$scope.Share = Share;
	
});