In my Angular directive, the template structure is as follows:
<Button id="testBtn">Test me<button>
Within the directive controller, I have defined API functions for the directive. Now, I need to send an event to the parent module when the button is clicked. This will allow me to specify the action to be taken on the button click in the main application.
The following code snippet should be added to the base application controller:
$scope.myDirective = {
btnClick:function(){
// define the function here
}
}
With the HTML template being structured like this:
<my-simpledirective='myDirective'></my-simpledirective>
I have managed to set up my configurations in the $scope.myDirective = {} section, but I am unsure how to define an event there.
For context, I am looking to achieve a similar functionality to how KendoUI handles events.
An alternative approach could be:
<my-simpledirective='myDirective' btn-clicked="myCustomClick"></my-simpledirective>
Then, in the base application controller:
$scope.myCustomClick = function(){
// function to be called when click event is received
}