Hi all,
I have an <input ng-model="name"> in the scope of a NameController. The
tricky part is I want this variable available to other controllers in my
app. I'm thinking of using a service with getters and setters to implement
this visibility to other controllers.
NameController
angular.module('app',[])
.controller('NameController', ['$scope', 'sharedService', function($scope
, 'sharedService') {
$scope.name = null;
$scope.setName = function() { sharedService.sharedName = name; };
}]);
angular.module('app')
.controller('OtherController', ['$scope', 'sharedService', function(
$scope, 'sharedService') {
$scope.name = getName();
$scope.getName = function() { return sharedService.name; };
}]);
angular.module('app')
.service('sharedService', function() {
var name = null;
return {
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.