Angular: Passing Object to Directive

http://angularjs.org/

by Gibrain Hernandez

HTML

<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
    <pass-object obj="obj()"></pass-object>
</div>

JavaScript

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

myApp.directive('passObject', function() {
    return {
        restrict: 'E',
        scope: { obj: '&' },
        template: '<div>Hello, ng-click="obj()" !</div>'
    };
});

myApp.controller('MyCtrl', function ($scope) {
    $scope.obj =function() { console.log( "world") };
});