Reputation: 1137
What is the advantage to using '&' instead of '<' for output bindings? '<' can receive a function from the parent, which can be called by the child, passing an argument from the child's scope to the parent's.
Further, it has a much more sensible syntax: Plain JavaScript instead of AngularJS parsing the argument names and requiring you to pass arguments as elements in an object.
Upvotes: 1
Views: 38
Reputation: 26940
The reason is that sometimes you want to pass other argument too, like this for example:
<directive ng-repeat="item in items" on-smth="dosmth($a, item)"></directive>
Inside directive (& binding):
scope.onSmth({ $a: internalVariable })
How would you do it with < binding?
scope.onSmth(internalVariable)
And in template:
<directive ng-repeat="item in items" on-smth="dosmth"></directive>
You can't pass additional item
parameter here.
Upvotes: 1