In AngularJS you can make a button to call an action like this:
<div ng-controller="myController">
  <button ng-click="onButtonClicked()">Click me</button>
</div>
So, I'm inserting a custom directive like this:
and in my-canvas.js directive file's link function I replace the tag with a KineticJS canvas. Then, User manipulate the canvas by dragging around Kinetic shapes and, finally, when User does with the shapes what he's required to do, I want the directive to call an action defined on myController. I'm thinking about something like this:
<div ng-controller="myController">
  <my-canvas ng-success="onScenarioSuccess" />
</div>
but I can't figure out how the correct way to do it.
How can I make a directive to call it's action/event programmatically?
 
                        
When you want your directive to expose an API for binding to behaviors you should use an isolate scope and use the
&local scope property. This allows you to pass in a function that the directive can invoke. Here is a simple example:And use it like:
As per the documentation:
There'are some more detail in the documentation.