I'm fetching some data with $http in a controller to show the user some data. But after this is done I don't want to do anymore fetches because the data is already fetched. However when going from one tab (controller) to another tab (controller) data is always fetched. My knowledge is limited to web and AngularJS. I thought below code would work but data is always fetched.
// We already have data don't bother to get it again
if (angular.isDefined($scope.data)) {
console.log("Already got data, no fetch");
return;
} else {
console.log("Fetch data first time");
}
$http.post('/api/data'......