Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-controller="TestCtrl">
  <my-directive my-on-click="ctrlOnClick()"></my-directive>
</body>
</html>
 
var myApp = angular.module('myApp', []);
myApp.controller('TestCtrl', function($scope) {
  $scope.ctrlOnClick = function() {
    alert('Hey!');
  }
});
myApp.directive('myDirective', function() {
  return {
    restrict: 'E',
    scope: {
      'myOnClick': '&'
    },
    template: '<button ng-click="myOnClick()">Click me</button>',
    replace: true
  }
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers