I have a directive that accepts an object as a parameter. I would like to pass to this parameter either the object or a method that returns the object.

You can [view on JsFiddle](https://jsfiddle.net/5wax9acc/2/) and here's the code:

**HTML**

```
<div ng-controller="Ctrl as vm">
  <my-directive user="{id: 1, name: 'Mike'}"></my-directive>
  <my-directive user="vm.getUser()"></my-directive>
</div>

```

**JS**

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

app.controller('Ctrl', function() {
  var vm = this;

  this.getUser = function() {
    return {id: 2, name: 'John'};
  };
})

app.directive('myDirective', function() {
  return {
    bindToController: {
      user: '='
    },
    controller: function() {
      var vm = this;
    },
    controllerAs: 'vm',
    replace: true,
    restrict: 'EA',
    scope: {},
    template: '<div>Name: {{vm.user.name}}</div>'
  };
});

```

If I set the parameter's type to `=` like above, I get the following error:

```
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!

```

[AngularJS - Error Reference](https://docs.angularjs.org/error/$rootScope/infdig?p0=10&p1=%5B%5B%7B%22msg%22:%22fn:%20regularInterceptedExpression%22,%22newVal%22:%7B%22id%22:2,%22name%22:%22John%22%7D,%22oldVal%22:%7B%22id%22:2,%22name%22:%22John%22%7D%7D%5D,%5B%7B%22msg%22:%22fn:%20regularInterceptedExpression%22,%22newVal%22:%7B%22id%22:2,%22name%22:%22John%22%7D,%22oldVal%22:%22...%22%7D%5D,%5B%7B%22msg%22:%22fn:%20regularInterceptedExpression%22,%22newVal%22:%7B%22id%22:2,%22name%22:%22John%22%7D,%22oldVal%22:%22...%22%7D%5D,%5B%7B%22msg%22:%22fn:%20regularInterceptedExpression%22,%22newVal%22:%7B%22id%22:2,%22name%22:%22John%22%7D,%22oldVal%22:%22...%22%7D%5D,%5B%7B%22msg%22:%22fn:%20regularInterceptedExpression%22,%22newVal%22:%7B%22id%22:2,%22name%22:%22John%22%7D,%22oldVal%22:%22...%22%7D%5D%5D)

---

What's the right approach to achieve what I'm after?