The problem is simple, I have this component, that gets the last searched items I saved in the sessionSotrage, which is an array of ListItem objects:
export class SearchlistComponent {
results = JSON.parse(<string>sessionStorage.getItem("lastSearch"));
}
And the html just prints them with the according link to access the pages via routing:
<ul class="list-group mt-3">
<li class="list-group-item" *ngFor="let result of results">
<div *ngIf="result.itemType == 'hospital'">
<div routerLink='/hospital/{{result.itemId}}'>
<h4>{{result.itemName}}</h4>
<h5>{{result.itemLocation}}</h5>
</div>
</div>
<div *ngIf="result.itemType == 'ward'">
<div routerLink='/ward/{{result.itemId}}'>
<h4>{{result.itemName}}</h4>
<h5>{{result.itemLocation}}</h5>
</div>
</div>
<div *ngIf="result.itemType == 'medic'">
<div routerLink='/medic/{{result.itemId}}'>
<h4>{{result.itemName}}</h4>
<h5>{{result.itemLocation}}</h5>
<h6 *ngIf="result.itemType == 'medic'">{{result.itemDescription}}</h6>
</div>
</div>
</li>
When accessing the page the list gets printed like normal, but when I click on the item I want to access the page of, the route doesn't have the value attached, so instead of having '/hospital/hospitalId' I get '/hospital'.
This only happens if I run the site using SpringBoot but not by using ng serve. I already checked if it was a parsing error and it wasn't, the data gets stored correctly and it gets printed accordingly. What could the problem be?