Last active
December 17, 2015 04:19
-
-
Save dragonfire1119/5549724 to your computer and use it in GitHub Desktop.
Angularjs transfer data to another controller. Found this on stack overflow saved me hours of looking.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myApp.services', []) | |
.service('emailService', function ($rootScope){ | |
var text = 'start value'; | |
return { | |
saveEmail:function (data){ | |
text = data; | |
$rootScope.$broadcast('new_message'); | |
}, | |
getEmail:function (){ | |
return text; | |
} | |
}; | |
}); | |
function SignupCtl($scope, emailService) { | |
$scope.$on('new_message', function(){ | |
window.alert(emailService.getEmail()); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment