Created
April 7, 2011 14:51
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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