As I continue to enhance my application, I am working on giving a directive the ability to display additional buttons (for various actions) by passing an object to it.
Although I can successfully display the button, I am facing the challenge of executing a function when that button is clicked.
The object itself contains a mix of strings and functions, as shown below:
<tablegrid
table="flavorings"
additional-buttons="[{name: 'add', onclick: 'function(){ }', icon: 'fa fa-plus'}]"
show-actionbutton="true"
show-rating="true"
show-search="true"
show-rowcheckbox="true"
show-header="true">
</tablegrid>
The template for my directive looks like this:
<button ng-repeat="aB in additionalButtons" class="btn btn-primary" ng-click="ab.onclick" type="button">
<i ng-class="aB.icon" ng-show="aB.icon != ''" aria-hidden="true"></i>
<span>{{ 'TABLEGRID_'+aB.name | uppercase | translate }}</span>
</button>
I am seeking guidance on how to properly execute the onclick function. Can you help me with this?