Hey there, I'm new here on Stack and hoping someone can lend a hand because I've hit a roadblock!
I'm working with an AngularJS script that generates multiple icons using data from a simple array. Each icon is linked to a YouTube video.
The code snippet below shows how straightforward the array and function are:
app.controller('videolist', function ($scope, $http) {
$scope.videos = ['q_664lrmyGE','q_664lrmyGE','dWuEVSCw8B8','3Wm3G8s8bxk','_ppuCZR8Mkw','9gN_cmK9TUc','s7lVGhTPQAY','_rNmmHXEdTc','blr-qDffIq0','_70M4lkLKPk','wjB9JtTU7SU','BGh1xc-O0WA','uxEBK9q686c','ToO-tS-X2U4','AKrmrbCTNxc'];
$scope.icon = [];
// add youtube videos
for (i=0; i<$scope.videos.length; i++) {
$scope.icon.push({id: $scope.videos[i], thumb: 'mqdefault'});
}
});
Now my goal is to load the array from an external JSON file.
I've attempted various methods, but none seem to be successful. How can I achieve this? And what should the structure of the JSON file look like? Most examples I've come across have records with two or three values, often in a "label":"value" pair.
Any guidance would be greatly appreciated!!