There were a lot of similar questions about stack overflows, but using tips didn't help.
I am learning angular.js and experimenting with $ http.get in the API, but am having trouble assigning a response to a variable.
The download request below is executed at boot time. (this is my app.js file)
var app = angular.module('store',[]);
app.controller("StoreController", function($scope,$http){
var request = $http.get('/test').then(function (response) {
$scope.data = response;
return response;
});
request.then(function (data) {
this.products = $scope.data
});
});
Below is the response from the request (I see this in the browser console view, but the data is not displayed.)
[
{
name: 'Dowayne',
surname: 'Breedt',
catchphrase: 'wallawallabingbangamIright?',
reviews: [
{
stars: 5,
body: 'i love stuff',
soldOut: false,
},
{
stars: 4,
body: 'meh',
soldOut: true,
},
{
stars: 3,
body: 'shittake mushrooms',
soldOut: false,
},
]
}
];
This is all garbage data (only for practice), but I can’t understand for life why it will not be displayed on the HTML page, if I assign the above fragment directly to this product, then it works fine /
What am I missing?
Thank.