Created
March 18, 2015 07:55
-
-
Save hsuh/1a087fe39e67aae7910f to your computer and use it in GitHub Desktop.
angularjs directive to directive communication (directive's controllers)
This file contains 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("child", function() { | |
return { | |
... | |
require: ["^parent", "child"], | |
link: function(scope, elem, attrs, ctrls) { | |
var parentController = ctrls[0], | |
childController = ctrls[1]; | |
childController.setParent(parentController); | |
}, | |
controller: ["$scope", function($scope) { | |
var parentController; | |
this.setParent = function(parent) { | |
parentController = parent; | |
}; | |
// use parentController... | |
}] | |
}; | |
}); | |
http://stackoverflow.com/questions/25075762/how-do-you-call-a-parent-directive-controller-from-a-child-controller-not-link |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment