0
我有一個接受它得到立即禁止使用輸入正確的值時,字符的輸入框NG-禁用角JS:禁止輸入框不能持續在頁面刷新
但是當我移動到下一個項目,分組的下一個按鈕頁面刷新
= 4)& &
我需要能夠對問題的索引放置到高速緩存
localStorage.setItem();
控制器:
$scope.initializeGame = function() {
$scope.score = (localStorage.getItem("token")) ? parseInt(localStorage.getItem("token")) : 0;
$scope.scoreValue = $scope.score
$scope.noOfTries = 0;
$scope.original = $scope.pageTitle;
$scope.guess = null;
$scope.deviation = null;
$scope.verifyGuess = function() {
$scope.deviation = $scope.original - $scope.guess;
$scope.noOfTries = $scope.noOfTries + 1;
$scope.falseAnswer = $scope.deviation != 0;
if ($scope.deviation == 0 && $scope.noOfTries == 1) {
$scope.scoreValue = parseInt($scope.score, 10) + 1;
var token = $scope.scoreValue;
localStorage.setItem("token", token);
};
你沒有在localStorage中看到該項目嗎? – alphapilgrim
我更喜歡從ng-repeat語句返回的列表對象的方法,我如何使用正確回答的對象的索引號來記錄,例如,到本地存儲或任何其他方法來維持它已被回答。 – user3265817
你使用[ui-router](https://github.com/angular-ui/ui-router)嗎?因爲如果你在下一個頁面被解決之前,你可以調用一個函數來檢查下一個預期的id是否在你的本地被回答,如果是,就設置它。 – alphapilgrim