fix(slidebox): add delegate filter

This commit is contained in:
Adam Bradley
2014-12-10 08:25:44 -06:00
parent f2705c6376
commit 9f4faa4aa4
2 changed files with 8 additions and 3 deletions

View File

@@ -40,7 +40,8 @@ IonicModule
'$timeout',
'$compile',
'$ionicSlideBoxDelegate',
function($timeout, $compile, $ionicSlideBoxDelegate) {
'$ionicHistory',
function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory) {
return {
restrict: 'E',
replace: true,
@@ -106,7 +107,11 @@ function($timeout, $compile, $ionicSlideBoxDelegate) {
//Exposed for testing
this.__slider = slider;
var deregisterInstance = $ionicSlideBoxDelegate._registerInstance(slider, $attrs.delegateHandle);
var deregisterInstance = $ionicSlideBoxDelegate._registerInstance(
slider, $attrs.delegateHandle, function() {
return $ionicHistory.isActiveScope($scope);
}
);
$scope.$on('$destroy', deregisterInstance);
this.slidesCount = function() {

View File

@@ -38,7 +38,7 @@ describe('Ionic Angular Slide Box', function() {
$rootScope.$apply();
expect($ionicSlideBoxDelegate._registerInstance)
.toHaveBeenCalledWith(el.controller('ionSlideBox').__slider, 'superHandle');
.toHaveBeenCalledWith(el.controller('ionSlideBox').__slider, 'superHandle', jasmine.any(Function));
expect(deregisterSpy).not.toHaveBeenCalled();
el.scope().$destroy();