0
I am developing an application with IONIC 2 where I consume a REST webservice from an application that is running online. When opening the page, I request and display the information correctly on the screen, however, when an item is inserted or changed on the server, the view does not update, but when I exit and return to the page.
Some code snippets that are being used:
vision:
<span *ngFor="#item of depoimentos">{{item.nome)}}</span>
Controller class that initializes testimonials:
ngOnInit() {
this.service.findAll().subscribe(
data => {
this.depoimentos = data;
console.log(this.depoimentos);
if (this.depoimentos.length > 0) {
this.depoimentos[0].visivel = true;
}
}
)}
Excerpt from the service that makes the request:
findAll() {
return this.http.get(depoimentosURL)
.map(res => res.json())
.catch(this.handleError);
}
Remember: I am using Ionic 2, which works with the angular v2.0.0-beta.15
Bruno, it worked and meets your proposal for the question asked, but I was thinking about the amount of requests generated and if this could reduce performance generating wear in the user experience. Do you know of any method that would do the opposite? Like only perform an update if the base is different? I don’t know if this is possible.
– Gonzaga Neto