I find myself a bit perplexed about the optimal approach for modifying a value in an object once it has been retrieved from a server.
Here is my TypeScript Script:
import { Component, OnInit } from '@angular/core';
import { Response } from '@angular/http';
import { HttpService } from "../http.service";
@Component({
selector: 'app-list-animals',
templateUrl: './list-animals.component.html',
styleUrls: ['./list-animals.component.css'],
providers: [HttpService]
})
export class ListAgentsComponent implements OnInit {
constructor(private httpService: HttpService) { }
items: any[];
ngOnInit() {
this.httpService.getData()
.subscribe(
data => { this.items = data.resource; },
error => alert(error),
() => console.log("Finished")
);
}
}
This is how my template looks like:
<table class="standardTable">
<tr *ngFor="let item of items"><td>{{item.type}}</td><td>{{item.summary}}</td><td>{{item.cost}}</td><td>{{item.available}}</td><td><a [routerLink]="['/animals/edit', item.id]">Now edit an animal</a></td></tr>
</table>
If the item.type equals "cat", I am deliberating on how and where to change it to say "feline". Should I make the alteration in the service, the TypeScript file itself, or implement a pipe?