As I embark on my first Angular JS project, I find myself in need of exporting a JSON array from my controller to an external JSON file. Here is the snippet from my controller containing the JSON data:
Fantacalcio.controller('fantacalcioController', function($scope){
$scope.myTeam = [
{
Player: {
name: "Orestis",
surname:"Karnezis"
},
rating: "4.91",
team: "Udinese"
},
.....
Player: {
name: "Patrick",
surname:"Schick"
},
rating: "6.97",
position: "forward",
team: "Sampdoria"
}
];
});
And here is how I've set up my component:
Fantacalcio.component('table', {
templateUrl: 'components/table.html',
controller: 'fantacalcioController'
});
I am now looking for guidance on how to store this JSON array in an external JSON file. I understand that I should utilize $http to make a get request, but I am unsure of how to implement it. I attempted following this solution https://docs.angularjs.org/tutorial/step_07 without success.
Any help would be greatly appreciated.