Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jrgcubano/9b7d01f5401f84d1dfe1 to your computer and use it in GitHub Desktop.
Save jrgcubano/9b7d01f5401f84d1dfe1 to your computer and use it in GitHub Desktop.
AngularJS: Including multiple controllers in a directive.
app.directive('myDirective', function () {
return{
restrict: "A",
require:['^parentDirective', '^ngModel'],
link: function ($scope, $element, $attrs, controllersArr) {
// parentDirective controller
controllersArr[0].someMethodCall();
// ngModel controller
controllersArr[1].$setViewValue();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment