Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49217

Get request getting into an infinite loop

$
0
0

@sneceesay77 wrote:

I have a rather long question but I think it may be trivial issue. I have some data stored in my MySQL back end. I am using PHP to fetch the data is display in in my view. My setup is simple. I have a restaurant and likes table. So for each restaurant I want to display its like count. My approach is below.

In my service.ts file, I have a simple function that gets to a php URL.

 getLikes(id){
    return this.http.get(this.LIKECOMMENTHANDLER);
 }

In my component.module.ts file, I used the above function and simply log the response

getLikesCount(id){
    //console.log("my id "+id);
    this.restaurantInfo.getLikes(id).subscribe(
      (response)=> {console.log(response)},
      (error) => console.log(error)
    );
  }

I called the above function in my template.html file as follows.


<ion-card *ngFor="let restaurant of restaurants" (click)="navigateToRestaurantDetailsPage('RestaurantDetailsPage', restaurant)">
  //display restaurant information here then
   <ion-col>
   <button ion-button icon-left clear small>
    <ion-icon name="thumbs-up"></ion-icon>
    <div>{‌{getLikesCount(restaurant.id)}}</div>
   </button>
  </ion-col>
</ion-card>

The code keeps running and never stops and it creates a memory leak.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49217

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>