fix($compile): fix memory leak

For functions that have a '&' binding on the scope, change the function from an inline definition to an external definition so the function closure has no access to the parent scope.

Closes #6794

Note: I am not sure this if this is a Chrome GC bug (as the function never uses the parent scope), but for the scenario from the issue, the patch fixes the leak