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);
};
幻燈片已經被定義爲一個範圍? – GY22
不,如上所述,幻燈片是一個$ ionicSlideBoxDelegate方法,調用它:$ ionicSlideBoxDelegate.slide($ localStorage.localStorageSliderCurrentIndex) –
這樣做會將值設置爲0 – GY22