У меня есть следующий заводской сервис в angularjs:Синтаксическая ошибка в AngularJS заводской службы
'use strict';
angular.module('gameApp_services').factory('sessionService', ['$http', function($http) {
return {
set:function(key, value) {
return sessionStorage.setItem(key,value);
},
get:function() {
return sessionStorage.getItem(key);
},
destroy:function()
return sessionStorage.removeItem(key);
}
};
}]).factory('loginService', function($http,$location,sessionService) {
return {
login: function(data, scope) {
var $promise = $http.post("lib/action.php", data); //send data to action.php
$promise.then(function(msg) {
var uid = msg.data;
if(uid) {
//scope.msgtxt='Correct information';
sessionService.set('user', uid);
$location.path('/game');
} else {
scope.msgtxt='Incorrect information';
$location.path('/firstpage');
}
});
},
logout:function() {
sessionService.destroy('user');
$location.path('/firstpage');
}
}
});
Когда я запускаю это, я получаю сообщение об ошибке:
SyntaxError: syntax error
return sessionStorage.removeItem(key);
Как следует синтаксис выглядеть? Кто может мне помочь? У меня нет идеи.
Вам не хватает открытия '{' функции. –