My controller code snippet is shown below. I am trying to access the value of $scope.FCGId. How can I access this variable?
angular.module('hotelApp.controllers')
.controller('menuCtrl', ['$scope','menu'
function($scope,'menu') {
$scope.categories = [];
$scope.FCGId = 0
$scope.items = [];
$scope.getCategories = function() {
menu.getCategories().success(function(data) {
$scope.categories = data;
$scope.FCGId = data['rows'][0].GRPCOD;
});
}
$scope.getItems = function(gropuId) {
menu.getItems(gropuId).success(function(data) {
$scope.items = data;
console.log(data);
});
}
$scope.$on('$ionicView.afterEnter', function() {
$scope.getCategories();
console.log($scope.FCGId);
$scope.getItems($scope.FCGId);
});
}
]);
The code above is returning 0 instead of the updated value from the getCategories() function.