I have this code:
JS:
angular.module("module") .controller("fooController", ["$scope", function($scope) { ... }) .directive("foo", function() { return { restrict: "E", controller: "fooController", link: function($scope, $element, $attrs) {
HTML:
<html> <head> </head> <body ng-app="module"> <foo/> <bar/> </body> </html>
The foo directive works, but the bar directive throws an error: No controller: fooController .
How can I fix this by preserving the current structure (the controller is not inside HTML, but used by directives, bar is outside foo and uses the same controller, and both change its scope)? I read the discussion here , but I could not figure out how to do this.
angularjs
tgkokk
source share