I'm wanting to write a directive in order to make a fab speed dial menu (https://material.angularjs.org/0.10.1-rc1/#/demo/material.components.fabSpeedDial) reusable, and although I can get everything working visually, I am having some problem with the "click" on a button ...
first of all, the directive itself:
angular.module('myApp')
.directive('myMenu',function(){
var ctrl = function () {
var controller = this;
};
return {
restrict: 'E',
controller: ctrl,
controllerAs: 'controller',
bindToController: true,
templateUrl: 'directives/myMenu.html',
scope: {
actions: '=',
class: '@',
}
};
});
and the template is
<md-fab-speed-dial md-direction="up" class="bottom-right">
<md-fab-trigger>
<md-button aria-label="menu" class="md-fab md-warn">
<md-icon md-font-icon="fa-plus" class="fa display-block icon-size-24" ></md-icon>
</md-button>
</md-fab-trigger>
<md-fab-actions ng-repeat="action in controller.actions">
<md-button aria-label="{{action.label}}" class="md-fab md-raised md-mini {{action.class}}" ng-click="action.click">
<md-icon md-font-icon="{{action.icon}}" class="fa display-block icon-size-18" ></md-icon>
</md-button>
</md-fab-actions>
</md-fab-speed-dial>
a snippet from the parent controller
controller.mainMenu = [
{
label: "Open",
click: "controller.open(true)",
class: "md-primary",
iconClass: 'fa',
icon: "fa-folder-open-o",
}
];
and, finally, the calling html
<my-menu actions="controller.mainMenu"/>
so, the problem I have is that the function defined by the action.click is never called. Is there a way of doing this, or am I going to have to create a "click" handler in the controller ?