Bonjour, je récupère avec http un arraylist de String depuis Java dans Angular, et j'aimerai pouvoir afficher chaque String via un Ngfor mais je n'y arrive pas. Dans mon typesciprt il y a un problème quand je récupère l'arraylist : Response with status: 200 OK for URL: http://localhost:8080/my-app/test' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

Bref voici le code Java qui retourne un array de string dans localhost 8080 :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
ArrayList<String> Clients = new ArrayList<String>();
 
		while (it.hasNext()) {
			String maString = "";
			Document doc = it.next();		
			maString = maString+" "+doc.get("nom");
			maString = maString+" "+doc.get("prenom");
			Clients.add(maString);
			System.out.println(Clients);
		}
 
	return Clients;
et voici comment j'essaie de le récupérer dans le typescript :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
public clients: Client[];
 
  constructor(private http: Http) { }
 
 
  ngOnInit() {
 
 
        this.http.get("http://localhost:8080/my-app/test").subscribe(result => {
        this.clients = result as Client[];
										}, error => console.error(error));
 
  }
Et enfin mon html :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 <div class="list-group">
 
 
        <p class="list-group-item-heading" *ngFor="let client of clients; let i = index">
          {{ client }} 
        </p>
 
    </div>
Merci d'avance !