我有这个文件leaderboard.service.js:
(function () {
'use strict';
angular
.module('App42')
.factory('LeaderboardService', LeaderboardService);
LeaderboardService.$inject = ['App42Service'];
App42.initialize();
function LeaderboardService(){
var result ;
var gameService = new App42Game();
gameService.getAllGames({
success: function(object) {
var game = JSON.parse(object);
result = game.app42.response.games.game;
console.log("result is " + result)
},
error: function(error) {
}
});
}
})();
而且我真的不知道如何编写带有将返回的函数的 return 语句,在这种情况下,我只想返回游戏列表。提前感谢您的帮助
我瘦了你错过了返回语句。你应该返回你的服务对象,比如:返回游戏服务。