I am a fan of the new arrow ()=>{}
syntax and would love to use it wherever possible. I understand that arrow functions point to the outer this context. Is there a way to modify an arrow function so that "this" points to its inner scope?
For example, how can I make this code:
let foo = () => {
// "this" keyword should reference the inner scope, not the window object
}
behave like this code:
function foo() {
// "this" keyword references the inner scope within the class/object/function/whatever-it's-called-fix-me-if-I'm-wrong
}
Is this achievable or do I have to stick with the function
keyword?
To be more specific, I need the "this" functionality in order to work with controllerAs syntax in Angular, but that's beside the point. This is more of a JavaScript question rather than an AngularJS one.