In this code my console.log logs undefined. I am trying to access $scope property from other $scope method. How to do this properly?
AppControllers.controller('DepartureLocationCtrl', [
'$scope','$http',
function($scope,$http){
$http.get('/airports').success(function(data){
$scope.departureLocations = data;
});
$scope.showSuggestions = function(){
console.log($scope.departureLocations);
}
$scope.showSuggestions()
}]);