In my service I have these methods:
getMap(): any {
return this.http.get(`someURL`);
}
getAssets(): any {
return this.http.get(`someURL`);
}
In my Component I use them like this:
ngOnInit() {
this.myService.getMap().subscribe(data => {
this.map = data; // Returns ["map-1.svg", "map-0.svg"]
});
this.systemMapService.getAssets().subscribe(data => {
this.assets = data; // Returns ["map-mapping-0.json", "map-mapping-1.json"]
});
}
In my template I want to use it like this:
<mat-tab-group mat-align-tabs="end">
<div *ngFor="let item of assets; let i = index">
<mat-tab label="{{i}}">
<div class="container">
<div class="map">
<img id="img_equipment" [src]="apiUrl + '/path/to/svg/' + item">
<a *ngFor="let link of map"
title="{{ link.title }}"
class="ink"
[ngStyle]="{ left: link.left, top: link.top, width: link.width }">
</a>
</div>
</div>
</mat-tab>
</div>
</mat-tab-group>
I provided the return values of the calls as comments in die code.
For example, the file map-0.svg
should use this JSON as a mapping map-mapping-0.json
. The file map-1.svg
then in turn this JSON file map-mapping-1.json
.
..and do the arrays that the calls return have to be sorted for it to work? Because unfortunately they are currently being returned unsorted by the backend.