Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. angular.module('childCallbacks', [])
  2. .directive('parentDir', function() {
  3. return {
  4. restrict: 'EA',
  5. bindToController: true,
  6. controller: 'parentCtrl',
  7. controllerAs: 'parent',
  8. template: '<div></div>'};
  9. })
  10. .directive('childDir', function() {
  11. return {
  12. restrict: 'EA',
  13. scope: {
  14. callbacks: '='
  15. },
  16. bindToController: true,
  17. controller: 'childCtrl',
  18. controllerAs: 'child',
  19. template: '<div></div>'
  20. };
  21. })
  22. .controller('parentCtrl', function() {
  23. this.callbacks = {};
  24.  
  25. this.handleSomeEvent = function() {
  26. // do some initial handling
  27.  
  28. // trigger child handling
  29. (this.callbacks.handleEvent || angular.noop)();
  30. };
  31. })
  32. .controller('childCtrl', function() {
  33. this.callbacks.handleEvent = function() {
  34. // handle event
  35. };
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement