kingstakh,
all: function() {
if(catgs != null) {return Promise.resolve(catgs);}
return $http.get('http://demo.wp-api.org/wp-json/wp/v2/categories/').then(function(res){
catgs = res.data;
console.log (catgs);
return catgs;
})
}
.controller('productsCtrl', function ($scope, catgs, $ionicSlideBoxDelegate, $window, $ionicGesture) {
//this array control the loading of pages so if the corresponding key of a slide is 'true', angular can load it's content'
$scope.ready = [];
$scope.$on("$ionicView.afterEnter", function (event, data) {
catgs.all().then(function(catgs) {
$scope.catgs = catgs;
angular.forEach($scope.catgs, function (value, key)
{
if(key===0) {
$scope.ready.push(0 + ': ' + true);
}
$scope.ready.push(key + ': ' + false);
});
})
});
$scope.changeSlide = function (index)
{
$scope.ready.push(index + ': ' + true);
};
})