1
は、私はデータページが更新だと私はそれを言及することを、私は検索し、stackoverflowのに掲示同様の質問を見つけ、消えている問題を持っているData will disappear after page refresh,予期しないトークン。私はangularjsに新しいです
私の工場サービス
app.factory("MoreInfoOnChallengeSvc", ["$window", function ($window) {
var data = localStorage.getItem("data")? JSON.parse(localStorage.getItem("data")) || {};
function setChallengeId(id){
data = id;
localStorage.setItem("data", JSON.stringify(data));
}
function getData(){
return data;
}
return{
setChallengeId: setChallengeId,
getData: getData
};
}]);
エラー:
EarnfitApp.js:240 Uncaught SyntaxError: Unexpected token ;
jquery-migrate-1.1.0.min.js:1'//@ sourceURL' and '//@ sourceMappingURL' are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead.
angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module earnfitApp due to:
Error: [$injector:nomod] Module 'earnfitApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.5.8/$injector/nomod?p0=earnfitApp
at http://localhost:2000/earnfitangular/angular/assets/js/angular.js:68:12
at http://localhost:2000/earnfitangular/angular/assets/js/angular.js:2082:17
at ensure (http://localhost:2000/earnfitangular/angular/assets/js/angular.js:2006:38)
at module (http://localhost:2000/earnfitangular/angular/assets/js/angular.js:2080:14)
at http://localhost:2000/earnfitangular/angular/assets/js/angular.js:4617:22
at forEach (http://localhost:2000/earnfitangular/angular/assets/js/angular.js:321:20)
at loadModules (http://localhost:2000/earnfitangular/angular/assets/js/angular.js:4601:5)
at createInjector (http://localhost:2000/earnfitangular/angular/assets/js/angular.js:4523:19)
at doBootstrap (http://localhost:2000/earnfitangular/angular/assets/js/angular.js:1758:20)
at bootstrap (http://localhost:2000/earnfitangular/angular/assets/js/angular.js:1779:12)
http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=earnfitApp&p1=Error…t%3A2000%2Fearnfitangular%2Fangular%2Fassets%2Fjs%2Fangular.js%3A1779%3A12)
私は私が間違っ
三項演算子の構文エラー:**正しいコード:** 'localStorage.getItem(" data ")? JSON.parse(localStorage.getItem( "data")):{}; '。 – Tushar