Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('childCallbacks', [])
- .directive('parentDir', function() {
- return {
- restrict: 'EA',
- bindToController: true,
- controller: 'parentCtrl',
- controllerAs: 'parent',
- template: '<div></div>'};
- })
- .directive('childDir', function() {
- return {
- restrict: 'EA',
- scope: {
- callbacks: '='
- },
- bindToController: true,
- controller: 'childCtrl',
- controllerAs: 'child',
- template: '<div></div>'
- };
- })
- .controller('parentCtrl', function() {
- this.callbacks = {};
- this.handleSomeEvent = function() {
- // do some initial handling
- // trigger child handling
- (this.callbacks.handleEvent || angular.noop)();
- };
- })
- .controller('childCtrl', function() {
- this.callbacks.handleEvent = function() {
- // handle event
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement