I'm attempting to execute a block of code outside of a function based on a variable obtained from a $http GET request but I'm struggling to achieve this.
$scope.myBooleanVariable = $http.get("url...");
if ($scope.myBooleanVariable) { // undefined
//perform something that must be outside of a function
}
This is a basic example of what I'm attempting to do, but with the http request being asynchronous the if case is always undefined(falsy). Is there any elegant way to achieve this?