import { Injectable, OnInit } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; @Injectable({ providedIn: 'root' }) export class PlotService { plotTypes: Array; tagFields: Observable; constructor(private http: HttpClient) { this.plotTypes = new Array(); this.plotTypes.push(new PlotType("Scatter")); this.plotTypes.push(new PlotType("Cumulative Distribution")); this.plotTypes.push(new PlotType("Parallel Requests")); this.plotTypes.push(new PlotType("Parallel Requests")); this.tagFields = new Array(); } ngOnInit() { } getPlotTypes(): Array { return this.plotTypes; } getTagFields(): Observable { const that = this; this.http.get('//localhost:8080/fields').subscribe(data => { data.forEach(function(name) { that.tagFields.push(new TagField(name)); }); }); return this.tagFields; } } export class PlotType { name: string; constructor(name: string) { this.name = name; } } export class TagField { name: string; constructor(name: string) { this.name = name; } }