diff options
| -rw-r--r-- | src/widgets.js | 2 | ||||
| -rw-r--r-- | test/widgetsSpec.js | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/widgets.js b/src/widgets.js index f1f46419..423fe6dd 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -373,7 +373,7 @@ angularWidget('@ng:repeat', function(expression, element){ cursor = iterStartElement; // current position of the node for (key in collection) { - if (collection.hasOwnProperty(key)) { + if (collection.hasOwnProperty(key) && key.charAt(0) != '$') { last = lastOrder.shift(value = collection[key]); if (last) { // if we have already seen this object, then we need to reuse the diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index b6754b91..90555325 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -290,6 +290,28 @@ describe("widget", function() { expect(element.text()).toEqual('misko:m:first|shyam:s:last|'); }); + it('should ignore $ and $$ properties', function() { + var scope = compile('<ul><li ng:repeat="i in items">{{i}}|</li></ul>'); + scope.items = ['a', 'b', 'c']; + scope.items.$$hashkey = 'xxx'; + scope.items.$root = 'yyy'; + scope.$digest(); + + expect(element.text()).toEqual('a|b|c|'); + }); + + it('should repeat over nested arrays', function() { + var scope = compile('<ul>' + + '<li ng:repeat="subgroup in groups">' + + '<div ng:repeat="group in subgroup">{{group}}|</div>X' + + '</li>' + + '</ul>'); + scope.groups = [['a', 'b'], ['c','d']]; + scope.$digest(); + + expect(element.text()).toEqual('a|b|Xc|d|X'); + }); + describe('stability', function() { var a, b, c, d, scope, lis; |
