The solution was almost as Scott said. $eval in a component doesn't work, even $rootScope.$eval so I used the function eval() and in the controller I bind my custom function to the $rootScope to be executed in menuitem component.
1) In menuitem.html (menuitem component) -> add data-ng-click="$ctrl.evaluateAction()"
<button data-ng-click="$ctrl.evaluateAction()"></button>
2) In the component controler (menuitem.js) -> add evaluateAction()
function menuitemController($rootScope, $scope, $element, $attrs) {
var ctrl = this;
...
ctrl.evaluateAction = function(){
eval(ctrl.action);
}
}
angular.module('app')
.component('appMenuitem', {
transclude: false,
controller: menuitemController,
bindings :{
label : '@',
...
action: '@'
},
templateUrl: 'angular/components/menuitem/menuitem.html'
});
3) In menu.html (Menu Component) add the action attribute
<comp-menuitem data-ng-repeat="item in items" action="{{ item.action }}"></comp-menuitem>
4) In the main controller - add the custom function as $rootScope.openDialog()...
angular.module('app')
.controller('MainController', ['$rootScope', '$scope', function($rootScope, $scope){
$rootScope.openDialog = function(key){
if(key === 'open'){
alert("open");
}
};
...
5) Add the action attribute data in the JSON
{ label : "foo" , action: "$rootScope.openDialog('open')"}
And it works !!!!