var app = angular.module('myApp', []); app.factory('instance', function(){ return {}; }); app.controller('MainCtrl', function($scope, instance) { $scope.change = function() { instance.name = $scope.test; }; }); app.controller('sideCtrl', function($scope, instance) { $scope.add = function() { $scope.name = instance.name; }; });
html:
<div ng-controller="MainCtrl"> <input type="text" ng-model="test" /> <div ng-click="change()">click me</div> </div> <div ng-controller="sideCtrl"> <div ng-click="add()">my name {{name}}</div> </div>