Skip to content

Instantly share code, notes, and snippets.

@wcc526
Created March 15, 2015 10:21
Show Gist options
  • Save wcc526/7f4465e02a794b4fa512 to your computer and use it in GitHub Desktop.
Save wcc526/7f4465e02a794b4fa512 to your computer and use it in GitHub Desktop.
event.js
.controller('homeListCtrl',['$scope','$rootScope','$http','homeService',
function($scope,$rootScope,$http,homeService){
$scope.selectUser = function(user){
homeService.setCurrentUser(user);
$rootScope.$broadcast('userChanged');
}
}])
.controller('homeDetailCtrl',['$scope','homeService',
function($scope,homeService){
$scope.$on('userChanged',function(event){
$scope.currentUser = homeService.getCurrentUser()
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment