So I know you can get a function in a directive to fire a function in a controller (see : AngularJS - pass function to directive ), however, right now I am trying to acheive something slightly different.
I'm trying to have a function in a controller fire a function inside a controller in the directive (so handled within the directive). So I click the button from the controller outside the directive, and it fires a function inside the directive.
Here is what I have tried
The directive:
return {
restrict: 'A',
replace: true,
controller: EditorCtrl.componentName,
scope: {
content: '=',
requestNow: '@'
},
templateUrl: 'editor.html'
};
The directive in use :
<div cengage-file-editor content="XmlContent" request-now="changeXml()"></div>
the outer controllers function:
$scope.changeXml = function(){
//fire function inside directive controller?
};
The function inside the directive controller:
$scope.changeXml = function(){
console.log("hit");
}
So basically, I want the user to have fired the changeXml function (outside of the directive) and have it send into the directive and connect and fire a function inside there. Not sure how to accomplish this, would love some help. Thanks!