Angular:
http://angularjs.org/
by mrajcok
HTML
<div ng-controller="MyCtrl">
<map set-fn="setDirectiveFn(theDirFn)"></map>
<button ng-click="directiveFn()">call directive function</button>
</div>
JavaScript
var app = angular.module('myApp',[]);
app.directive('map', function() {
return {
restrict: 'E',
replace: true,
scope: { setFn: '&' },
template: '<div></div>',
link: function(scope, element, attrs) {
scope.updateMap = function() {
alert('inside updateMap()');
}
scope.setFn({theDirFn: scope.updateMap});
}
}
});
function MyCtrl($scope) {
$scope.setDirectiveFn = function(directiveFn) {
$scope.directiveFn = directiveFn;
};
}