Created
June 29, 2014 20:10
-
-
Save PatrickJS/fe34ac8059d0d6478f4c to your computer and use it in GitHub Desktop.
AngularJS: Including multiple controllers in a directive.
This file contains hidden or 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
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