Using AngularJS on the frontend, I have a variable named ttest
defined before making an $http
call. Subsequently, data is assigned to this variable.
The value of ttest[0]
is available within the $http
function but not outside of it.
angular.module('MyApp', ['ngMaterial', 'ngMessages', 'material.svgAssetsCache'])
.controller('AppCtrl', function($scope, $http, $log) {
var imagePath = 'img/list/60.jpeg';
var ttest = [];
var url = "https://www.w3schools.com/angular/customers.php";
$http.get(url).then(function(response) {
ttest = response.data;
$scope.messages = ttest;
$log.info(ttest[0]);
});
$log.info(ttest[0]);
});