Looking to update a controller to use the "controller as" syntax has presented some challenges. One issue that arose during the transformation process is the inability to access "scope" variables outside of a function. It seems that, based on my understanding, "this" references the object in which it is used.
this.scopeVariable = undefined;
this.fooFunction = function () {
resource.get()
.$promise.then(function (result) {
this.scopeVariable = result.foo;
});
};
When attempting to assign a value to scopeVariable using "this", am I actually trying to access an object from within fooFunction? If so, how can I retrieve an object from outside the function while still inside it?
Your input would be greatly appreciated!