Ionic 2 - refresh view without making another service call


#1

I’m still novice with Ionic and Angular so please bear with me –

I have a search field in which a user can enter the name of an item or start to type, a list of items with radio buttons appear to select and see related images populate below in the body upon selection. When a radio button is selected, the items are pushed to an array.

  <ion-navbar>
    <ion-searchbar [(ngModel)]="search" (ionInput)="getItems($event)"></ion-searchbar> 
**This ion-list element displays the items to be selected**
      <ion-list id="thingsList">
    <ion-item *ngFor="let item of items">
      <ion-label>{{ item.text }}</ion-label>
      <ion-checkbox id='things' (ionChange)="addToFavs(item)" color="success"></ion-checkbox>
    </ion-item>
  </ion-list>
**This ion-list below shows selected items that can be removed by clicking on trash icon**
  <ion-list>
      <ion-item *ngFor="let item of service.itemDisplay">
        {{ item.text }}
        <ion-icon ios="ios-trash" (click)="trashItem(item)"></ion-icon>
      </ion-item>
   </ion-list>
  </ion-navbar>
...

   <ion-list>
   <ion-row *ngFor="let post of feedService.feed"</ion-row>
</ion-list>

Here is my simplified typescript to run a function in the service provider to remove items:

trashItem() {
    this.service.toggleFavorite(obj); 
}

The associated images with any item are loaded via an API.

MY QUESTION:
After removing any item from the selected array, how can I refresh the page view to remove the associated content WITHOUT making another api call on init?

Thank you.


#2

“How can I refresh the page view” isn’t something you should generally need to be thinking about in an Angular application. When you modify bound properties (such as itemDisplay), Angular’s change detection should notice and automatically do what you would expect. Something is odd in your code if that’s not working, so you might want to think about posting something more complete and reproducible.