Skip to content

Instantly share code, notes, and snippets.

@PatrickJS
Created June 29, 2014 20:10
Show Gist options
  • Save PatrickJS/fe34ac8059d0d6478f4c to your computer and use it in GitHub Desktop.
Save PatrickJS/fe34ac8059d0d6478f4c 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