2016-05-29 56 views
0

我得到了這個離子項目,我已經實現了一個離子滑塊,現在我想跟蹤滑塊的頁面滑塊並將其存儲在本地存儲中。我正在使用ngStorage節省本地存儲但不適用的價值(Ionic-ngStorage)

我能夠跟蹤滑塊的當前索引並將其存儲在本地存儲中,但是當我在瀏覽器中刷新頁面時,滑塊索引從頭開始。我在做什麼我的控制器代碼錯誤

部分:

$scope.next = function() { 
    // Then we make sure we update our index to the current slides index. 
    $scope.ui.index = $ionicSlideBoxDelegate.currentIndex(); 
    console.log($scope.ui.index); 
    $ionicSlideBoxDelegate.next(); 
    // Local storage 
    $scope.localStorageSliderCurrentIndex = $scope.ui.index; 
    $localStorage.localStorageSliderCurrentIndex = $scope.localStorageSliderCurrentIndex; 
    console.log('The local storage value for current slider index is ',$localStorage.localStorageSliderCurrentIndex); 

}; 

enter image description here

回答

0

我沒有看到slidebox有開始幻燈片索引的參數。但是,我看到ionicSlideBoxDelegate已「設置」方法:幻燈片(於[速]) 所以我認爲你可以在開始時間設置第一個索引:

$ionicSlideBoxDelegate.slide($localStorage.localStorageSliderCurrentIndex); 
+0

幻燈片已經被定義爲一個範圍? – GY22

+0

不,如上所述,幻燈片是一個$ ionicSlideBoxDelegate方法,調用它:$ ionicSlideBoxDelegate.slide($ localStorage.localStorageSliderCurrentIndex) –

+0

這樣做會將值設置爲0 – GY22