I'm trying to learn AngularJS, but there's one thing I can't wrap my head around.
What is the benefit of using "&" over "="? All the tutorials, demonstrations and documentation I've found tell me that & evaluates the expression in the parent scope. However, when I first tried doing callbacks to my controller from my directive, I just used a = binding to a function on the parent scope, and it worked fine.
For example, with a function on the controller's scope foo that takes a parameter bar, I could do a directive declaration like
scope: { callback: '=' },
template: '<div ng-click="callback(value)"></div>'
and include the directive like
<my-directive callback="foo"></my-directive>
To achieve the same with &, it seems like I have to do
scope: { callback: '&' },
template: '<div ng-click="callback({bar:value})"></div>'
and
<my-directive callback="foo(bar)"></my-directive>
From this, I don't really see the advantage. Have I misunderstood &?
EDIT: I suppose a valid addition to my question is: Is it a bad idea to bind to parent scope functions using = instead of &?