I keep getting an error in a simple for loop trying to insert value from one array to another. My JS code is as:
var myApp = angular.module('myApp', []);
myApp.controller('UserCtrl', function($http) {
let vm = this;
var datetime = [];
var venuename = [];
var venuecity = [];
var venuecountry = [];
var url = [];
var arr = [];
var id = "secret key";
vm.searchText;
var i=0;
vm.getByID = function() {
$http.get("https://rest.bandsintown.com/artists/" + vm.searchText + "?app_id="+id)
.then(response => {
console.log(response.data)
vm.name = response.data.name
vm.thumb = response.data.thumb_url
vm.fb = response.data.facebook_page_url
vm.up = response.data.upcoming_event_count
$http.get("https://rest.bandsintown.com/artists/" + vm.searchText + "/events" + "?app_id="+id)
.then(response2 => {
console.log(response2.data)
vm.arr = response2.data
console.log(vm.up)
console.log(vm.arr[0].datetime)
console.log(vm.arr[1].datetime)
for (i = 0; i <=(vm.up-1); i++){
vm.datetime[i] = vm.arr[i].datetime;
vm.venuename[i] = vm.arr[i].venue.name;
vm.venuecity[i] = vm.arr[i].venue.city;
vm.venuecountry[i] = vm.arr[i].venue.country;
vm.url[i] = vm.arr[i].url;
}
console.log(vm.up)
})
})
}
});
The datetime part of the arr returns just as i want it to. I just cant store it into the new array. What im trying to do is that the array 'arr' contains all the objects of concerts of an artist. I want to display the individual details, for that I need to store each element in a new array, and repeat to create and show separate event details. Im a newbie at this and any help would be appreciated. Thanks in advance!