我试图在Angular的字符串数组中打开一个具有多个值的对象。
我正在调用给我对象的REST API,但是我无法设法将值读入数组。
constructor(private httpService: HttpClient) { }
arrayMessages: string[];
ngOnInit() {
this.httpService.get('http://localhost:8080/greetings?message=hello', {responseType: 'json'})
.subscribe(
data => {
this.arrayMessages = data as string [];
console.log(this.arrayMessages);
}
);
}