Guest User

Untitled

a guest
Aug 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. var app = angular.module('myApp', []);
  2. app.controller('PersonController', ['$scope', function ($scope) {
  3. $scope.$watch('name', function (newValue) {
  4. $scope.$emit('nameChanged', newValue);
  5. });
  6. }]);
  7. /* name will go upwards until it reaches $rootScope */
  8. /* $rootScope will pass it to our controller */
  9. app.controller('GreetingController', ['$scope', '$rootScope', function ($scope, $rootScope) {
  10. $rootScope.$on('nameChanged', function (event, value) {
  11. $scope.name = value;
  12. });
  13. }]);
Add Comment
Please, Sign In to add comment