diff --git a/js/angular/directive/collectionRepeat.js b/js/angular/directive/collectionRepeat.js index 2454b1f42d..cb92687950 100644 --- a/js/angular/directive/collectionRepeat.js +++ b/js/angular/directive/collectionRepeat.js @@ -225,6 +225,11 @@ function($collectionRepeatManager, $collectionDataSource, $parse) { rerender($scope.$eval(listExpr)); } + // for lists inside a modal, recalc when the modal is shown + $scope.$on('modal.shown',function(){ + onWindowResize(); + }); + ionic.on('resize', onWindowResize, window); $scope.$on('$destroy', function() { diff --git a/test/unit/angular/directive/collectionRepeat.unit.js b/test/unit/angular/directive/collectionRepeat.unit.js index e3206d01fb..fda85c2c49 100644 --- a/test/unit/angular/directive/collectionRepeat.unit.js +++ b/test/unit/angular/directive/collectionRepeat.unit.js @@ -152,6 +152,24 @@ describe('collectionRepeat directive', function() { expect(scrollView.resize.callCount).toBe(1); }); + it('should rerender on modal popup', function() { + inject(function($rootScope) { + var el = setup('collection-repeat="item in items" collection-item-height="50"'); + var scrollView = el.controller('$ionicScroll').scrollView; + spyOn(scrollView, 'resize'); + dataSource.setData.reset(); + repeatManager.resize.reset(); + + el.scope().items = [1, 2, 3]; + + $rootScope.$broadcast('modal.shown'); + + expect(dataSource.setData).toHaveBeenCalledWith(el.scope().items); + expect(repeatManager.resize.callCount).toBe(1); + expect(scrollView.resize.callCount).toBe(1); + }); + }); + it('$destroy', function() { var el = setup('collection-repeat="item in items" collection-item-height="50"'); dataSource.destroy = jasmine.createSpy('dataSourceDestroy');