diff --git a/js/ext/angular/src/service/ionicView.js b/js/ext/angular/src/service/ionicView.js index 43836de5fe..fd219fb11b 100644 --- a/js/ext/angular/src/service/ionicView.js +++ b/js/ext/angular/src/service/ionicView.js @@ -152,6 +152,7 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform']) // they went back one, set the old current view as a forward view rsp.viewId = backView.viewId; rsp.navAction = 'moveBack'; + currentView.scrollValues = {}; //when going back, erase scrollValues if(backView.historyId === currentView.historyId) { // went back in the same history rsp.navDirection = 'back'; @@ -225,6 +226,7 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform']) stateName: this.getCurrentStateName(), stateParams: this.getCurrentStateParams(), url: $location.url(), + scrollValues: null }); // add the new view to this history's stack diff --git a/js/ext/angular/test/service/ionicViewService.unit.js b/js/ext/angular/test/service/ionicViewService.unit.js index dfe3d4d1e3..54f94392b2 100644 --- a/js/ext/angular/test/service/ionicViewService.unit.js +++ b/js/ext/angular/test/service/ionicViewService.unit.js @@ -140,6 +140,8 @@ describe('Ionic View Service', function() { rootScope.$apply(); registerData = viewService.register({}); currentView = viewService.getCurrentView(); + //Set test value for remembered scroll + currentView.scrollValues = 'foo'; backView = viewService.getBackView(); forwardView = viewService.getForwardView(); expect(backView.stateName).toEqual('about'); @@ -157,6 +159,7 @@ describe('Ionic View Service', function() { currentView = viewService.getCurrentView(); backView = viewService.getBackView(); forwardView = viewService.getForwardView(); + expect(forwardView.scrollValues).toEqual({}); expect(currentView.stateName).toEqual('about'); expect(currentView.backViewId).toEqual(backView.viewId); expect(currentView.forwardViewId).toEqual(forwardView.viewId); @@ -337,7 +340,7 @@ describe('Ionic View Service', function() { expect(currentView.historyId).toEqual('root'); expect(rootScope.$viewHistory.histories.root.cursor).toEqual(0); expect(homeReg.navAction).toEqual('initialView'); - + // each tab gets its own history in the tabs directive // create a new tab and its history var tabs1Container = { $parent: rootViewContainer }; @@ -566,7 +569,7 @@ describe('Ionic View Service', function() { expect(rootScope.$viewHistory.histories[tab1Scope.$historyId].stack.length).toEqual(2); expect(registerData.navAction).toEqual('moveBack'); expect(registerData.navDirection).toEqual('back'); - + // render first view in tab2 var tab2view1Scope = { $parent: tab2Scope }; $state.go('tabs.tab2view1');