Skip to content

Instantly share code, notes, and snippets.

@mewdriller
Created September 1, 2015 22:03
Show Gist options
  • Save mewdriller/8b7d80752a4bf92eff5f to your computer and use it in GitHub Desktop.
Save mewdriller/8b7d80752a4bf92eff5f to your computer and use it in GitHub Desktop.
bindToController, controllerAs, postLink w/ vm access
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