Created
September 1, 2015 22:03
-
-
Save mewdriller/8b7d80752a4bf92eff5f to your computer and use it in GitHub Desktop.
bindToController, controllerAs, postLink w/ vm access
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
function childDirective() { | |
'ngInject'; | |
function postLink(scope, element, attribute, [vm, ParentController]) { | |
// Initialization: | |
ParentController.register(vm); | |
// Handlers: | |
element.on('click', (event) => { | |
vm.triggerChild(); | |
}); | |
} | |
return { | |
bindToController: { | |
child: '=', | |
key: '@', | |
onComplete: '&', | |
}, | |
controller: 'ChildController', | |
controllerAs: 'vm', | |
link: postLink, | |
require: ['ChildController', '^ParentController'], | |
scope: {}, | |
}; | |
} | |
export default childDirective; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment