Skip to content

Instantly share code, notes, and snippets.

@vojtajina
Created April 7, 2011 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vojtajina/907914 to your computer and use it in GitHub Desktop.
Save vojtajina/907914 to your computer and use it in GitHub Desktop.
Angular issue: There is a different this (inside the method - different scope object), if controller method is defined in instance than if defined in prototype. This applies only when related element has been created by ng:repeater.
// controller
function MyCtrl() {
this.instMethod = function() {
return this.$id;
};
}
MyCtrl.prototype.protoMethod = function(index) {
return this.$id;
};
// template
<ul>
<li ng:repeat="i in [1]">
{{instMethod()}} == {{protoMethod()}}
</li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment