mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix(ng:repeat): repeater should ignore $ and $$ properties
This commit is contained in:
parent
07926ff1ef
commit
833eb3c844
2 changed files with 23 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue