mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-05 22:35:14 +08:00
fix(ngRepeat): correctly apply $last if repeating over object
If the $last property is calculated from the original collectionLength on an object and properties starting with $ were filtered out, then $last is never applied and $middle is applied erroniously. Closes #1789
This commit is contained in:
committed by
Igor Minar
parent
7c60151cb8
commit
ed2fd2d0ca
@@ -293,6 +293,21 @@ describe('ngRepeat', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should calculate $first, $middle and $last when we filter out properties from an obj', function() {
|
||||
element = $compile(
|
||||
'<ul>' +
|
||||
'<li ng-repeat="(key, val) in items">{{key}}:{{val}}:{{$first}}-{{$middle}}-{{$last}}|</li>' +
|
||||
'</ul>')(scope);
|
||||
scope.items = {'misko':'m', 'shyam':'s', 'doug':'d', 'frodo':'f', '$toBeFilteredOut': 'xxxx'};
|
||||
scope.$digest();
|
||||
expect(element.text()).
|
||||
toEqual('doug:d:true-false-false|' +
|
||||
'frodo:f:false-true-false|' +
|
||||
'misko:m:false-true-false|' +
|
||||
'shyam:s:false-false-true|');
|
||||
});
|
||||
|
||||
|
||||
it('should ignore $ and $$ properties', function() {
|
||||
element = $compile('<ul><li ng-repeat="i in items">{{i}}|</li></ul>')(scope);
|
||||
scope.items = ['a', 'b', 'c'];
|
||||
|
||||
Reference in New Issue
Block a user