I am adapting a controller to the "controller as" syntax. But while transforming the code, I remarked that I can't access the "scope" variables with this out of a function. If I understand the concept of this, then this does access the object it is used in. As example this code:
this.scopeVariable = undefined;
this.fooFunction = function () {
resource.get()
.$promise.then(function (result) {
this.scopeVariable = result.foo;
});
};
So when I try to set the scopeVariable with this, I actually try to access an object from fooFunction, right? If this is the case, how can I grab an object outside of the function within the function?
Thanks for your answers!