Forked from PatrickJS/directive- multiple-controllers.js
Created
October 5, 2015 10:58
-
-
Save jrgcubano/9b7d01f5401f84d1dfe1 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