Question: Goal: I need to execute a method in a directive template html , the method is a member of an object which is passed to directive scope.

I am trying to get "Hello, world!" output. Can some one help please.

html:

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

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

myApp.controller('MyCtrl', function ($scope) {
    $scope.obj = { func1: "$scope.function1.toString()" };

  $scoe.function1 = function() {
    return "world!";
  };
});
```

```html
<div ng-controller="MyCtrl">
    <pass-object obj="obj"></pass-object>
</div>
```

Answer: 
First of all you need to define the function before you create the object.
Second you need to pass the function definition not the function call to the object(without '()').

```js
var myApp = angular.module('myApp',[]);
myApp.directive('passObject', function() {
    return {
        restrict: 'E',
        scope: { obj: '=' },
        template: '<div>Hello, {{obj.func1()}}!</div>'
    };
});

myApp.controller('MyCtrl', function ($scope) {
    $scope.function1 = function() {
        return "world!"; // here you can call .toString() if needed
    };
    $scope.obj = { func1: $scope.function1 };
});
```

```html
<div ng-controller="MyCtrl">
    <pass-object obj="obj"></pass-object>
</div>
```
```
var myApp = angular.module('myApp',[]);

myApp.directive('passObject', function() {
return {
    restrict: 'AE',
    scope: { obj: '&obj' },

    template: '<div>Hello, {{obj()}}!</div>'
};
});

 myApp.controller('MyCtrl', function ($scope) {

$scope.obj = { func1: $scope.function1 };

$scope.function1 = function() {
    return "world!";
};
});

<div ng-app="myApp">
 <div ng-controller="MyCtrl">
     <pass-object obj="function1()"></pass-object>
 </div>

```

 You can also pass the function in the directive and call it.. this works for me ..