I'm facing a basic issue that I can't seem to solve - my code isn't working as expected:
<article id="desktop">
<h3>Content: </h3>
<ul>
<li ng-repeat="x in storage">
name: {{x.name}}
</li>
</ul>
</article>
Here's the AngularJS part of my code:
$scope.storage = [];
...
$scope.showDesktop = function(){
$http.get("/getDesktop").then(function(response){
for(var i = 0; i<response.data.length; i++){
$scope.storage.push({
name: response.data[i]
});
}
console.log($scope.storage);
return;
});
}
I suspect there might be a syntax error somewhere, even though I've checked the documentation and used the correct ng-repeat syntax.
Although the console.log shows the correct content, it still doesn't work as intended.
This is how my Spring controller is implemented:
//Returns Desktop
@GetMapping("/getDesktop")
public ArrayList<String> getDesktop() throws Exception {
ArrayList<String> itemNames = new ArrayList<>();
if(kdxF.getLogged() && kdxF.getUser() != null) {
itemNames = kdxF.showDesktop();
}else {
throw new Exception("Not logged in!");
}
return itemNames;
}