Skip to content

Commit

Permalink
fix(ionRefresher): be sure to run on-refresh with an angular digest
Browse files Browse the repository at this point in the history
Closes #1465
  • Loading branch information
ajoslin committed May 22, 2014
1 parent bfce8e2 commit 979f7b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
22 changes: 12 additions & 10 deletions js/angular/directive/refresher.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* @ngdoc demo
* @name ionRefresher#withAList
* @module refresherList
* @javascript
* @javascript
* angular.module('refresherList', ['ionic'])
* .controller('RefresherCtrl', function($scope, $timeout) {
* $scope.items = ['Item 1', 'Item 2', 'Item 3'];
Expand All @@ -81,19 +81,19 @@
* <ion-header-bar class="bar-positive">
* <h1 class="title">Refresher</h1>
* </ion-header-bar>
*
*
* <ion-content ng-controller="RefresherCtrl">
*
* <ion-refresher on-refresh="doRefresh()"
* pulling-text="Pull to refresh..."
* refreshing-text="Refreshing!"
*
* <ion-refresher on-refresh="doRefresh()"
* pulling-text="Pull to refresh..."
* refreshing-text="Refreshing!"
* refreshing-icon="ion-loading-c">
* </ion-refresher>
*
*
* <ion-list>
* <ion-item ng-repeat="item in items">{{item}}</ion-item>
* </ion-list>
*
*
* </ion-content>
*/
IonicModule
Expand Down Expand Up @@ -133,8 +133,10 @@ IonicModule

scrollCtrl._setRefresher($scope, $element[0]);
$scope.$on('scroll.refreshComplete', function() {
$element[0].classList.remove('active');
scrollCtrl.scrollView.finishPullToRefresh();
$scope.$evalAsync(function() {
$element[0].classList.remove('active');
scrollCtrl.scrollView.finishPullToRefresh();
});
});
};
}
Expand Down
3 changes: 3 additions & 0 deletions test/unit/angular/directive/refresher.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ describe('ionRefresher directive', function() {
var ctrl = el.controller('$ionicScroll');
expect(ctrl.scrollView.finishPullToRefresh).not.toHaveBeenCalled();
el.scope().$broadcast('scroll.refreshComplete');
expect(el.hasClass('active')).toBe(true);
expect(ctrl.scrollView.finishPullToRefresh).not.toHaveBeenCalled();
el.scope().$apply();
expect(el.hasClass('active')).toBe(false);
expect(ctrl.scrollView.finishPullToRefresh).toHaveBeenCalled();
});
Expand Down

0 comments on commit 979f7b5

Please sign in to comment.