Controller prototype / instance methods #321
Description
There is a different this
(inside controller method - different scope object), if method is defined in instance than if defined in prototype. And the method is invoked from child scope element (i.e. element created by repeater).
At least we should mention that in doc, as it's bit confusing.
There is a gist with example: https://gist.github.com/907914
Reason
Prototype methods are binded, so that they are always called with root (for given controller) scope as this
. See https://github.com/angular/angular.js/blob/master/src/Scope.js#L583
Instance methods (defined in constructor) are only applied, so that they are called with related scope as this
. (that's child scope inside repeater)
Possible solution
Unify the API - do we need to bind the prototype methods ??? I hope we don't.
User has to access parent scope through $parent or $root property.