One way is to make a Service / Factory that will communicate with the controllers you want.
For example, here getter / setter Factory
.factory('factoryName', function () { var something = "Hello"; return { get: function () { return something; }, set: function (keyword) { something = keyword; return something ; } }; }])
And then in your controllers:
.controller('controllerOne', ['factoryName', function (factoryName) { $scope.test = factoryName.get(); }]); .controller('controllerTwo', ['factoryName', function (factoryName) { $scope.test = factoryName.get(); $scope.clickThis = function (keyword) { factoryName.set(keyword); }; }]);
I suggest reading about this: Can one controller call another?
eHx
source share