Here is my code and if the console.log(data) in browser is
app.component.ts:34 [{"SemesterId":"Fall 2017"},{"SemesterId":"Spring 2017"}]
How can I convert this json string to an array and display it? this.result1=data['SemesterId']; doesn't work. Please take a look.
interface semester {
SemesterId: string;
}
@Component({
selector: 'app-root',
template: `
<ul>
<li *ngFor="let h of result1">{{h}}</li>
</ul>
`,
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
constructor(private http: HttpClient) {
}
result1 :string;
r1:object;
ngOnInit(): void {
this.http.get('http://localhost:13043/students/courses/all').subscribe(
data=>{
this.result1=data['SemesterId'];
console.log(data);
}
)
}
}