What is the reason for not utilizing a service in your application? Services play a crucial role in sharing data between different parts of the application. One approach to achieve this is by exposing the service on each controller and binding ng-model
to that particular service.
JavaScript
angular.module('app', [])
.factory('User', [function () {
var service = {
username: null
};
return service;
}])
.controller('MainCtrl', ['$scope', 'User', function ($scope, User) {
$scope.User = User;
}])
.controller('SecondCtrl', ['$scope', 'User', function ($scope, User) {
$scope.User = User;
}]);
HTML
<div ng-controller="MainCtrl">
<input type="text" ng-model="User.username">
</div>
<div ng-controller="SecondCtrl">
<input type="text" ng-model="User.username">
</div>
Plunker: http://plnkr.co/edit/VSEHD970O0xWbu6OCPqB?p=preview