AngularJS isolated scope, parent method call

Example for http://stepansuvorov.com/blog/

by Stepan Suvorov

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div ng-controller="mainCtrl">
   <my-directive say="sayHello(name)"></my-directive>
</div>

JavaScript

var app = angular.module('app', []);


app.controller('mainCtrl', function ($scope) {
   $scope.sayHello = function(name){
     alert(name);
   }
});

app.directive('myDirective', function(){
    return {
        restrict: 'E',
        template: '<div><input ng-model="name"><button ng-click="say({name: name})">Say hello to {{name}}</button></div>',
        replace: true,
        scope: {
            say: '&'
        },
        link: function(scope){
           scope.name = 'Alice';
        }
    }
});