I'm trying to display an object I'm getting remotely through AJAX. The error I'm currently getting is:
ReferenceError: $stateParams is not defined
Here's what I have in services.js:
.factory('Games', function() {
var games = $.ajax({
"url":"https://www.kimonolabs.com/api/dc6n4edu?apikey=[APIKEY]&callback=kimonoCallback",
"crossDomain":true,
"dataType":"jsonp"
});
return {
all: function() {
return games;
},
get: function(gameID) {
// Simple index lookup
return games[gameId];
}
}
});
Here's what I have in controller.js:
.controller('AccountCtrl', function($scope, Games) {
console.log("test in controller");
$scope.game = Games.get($stateParams.gameId);
});
Here's what I have in tab-account.html:
<ion-list>
<ion-item ng-repeat="item in items">
Hello, {{item}}!
</ion-item>
</ion-list>
you are missing the $stateParams
value in the controller function... but i do think you should look into using $http
service or a resource
.controller('AccountCtrl', function($scope, $stateParams, Games) {
console.log("test in controller");
$scope.game = Games.get($stateParams.gameId);
});