Angular: Empty Fiddle

http://angularjs.org/

by miphe

HTML

<script src="https://code.angularjs.org/1.2.0-rc.2/angular.js"></script>
<div ng-app="myApp">
    <div ng-controller="ctrl">
        <p>{{ name }}</p>
    </div>
    
    <div my-directive>
        <p>{{ name }}</p>
    </div>
</div>

JavaScript

var myApp = angular.module('myApp',[]);
//myApp.factory('myService', function() {});

myApp.controller('ctrl', function($scope) {
    $scope.name = 'Superhero';
});

myApp.directive('myDirective', function() {
    return {
      restrict: "A",
      controllerAs: 'ss',
      controller: function($scope) {
        this.meth = function(data) {
          console.log('Woho! ', data);
        };
      },
    
      template: '<p ng-click="ss.meth(\'data\')">Should be unavailable: {{name}}</p>',
        compile: function() {
            return {
                pre: function preLink(scope, iElement, iAttrs, controller) {
                  console.log('pre...');
                },
                post: function postLink(scope, iElement, iAttrs, controller) {
                  console.log('post..');
                }
            };
        }
    };
});