Ionic Count likes

Hello,

I want to add in my a like system, when you click on the button it shows 1 (++), and when you clique again it shows 0(–), But also I want it to be in realtime, other people can see it.

I hope you understood me.

Thanks

1 Like

Please post some sample code… also what backend are you using ?

1 Like

27
Look at the screen, My app is like this, showing cards… I want to add two buttons (LIKE and DISLIKE) with Count number…
I don’t have a code, I’m trying to create this function…

If you want that people can like or dislike you need a backend for it.

Or will it be something like a test/show off dummy ?

1 Like

What do you mean by backend ?
I go an idea to use firebase, and people can see likes in realtime, not just in my device :confused:

1 Like

You need the backend to handle the likes, users, pictures and everything else.

Firebase is a very good option to use but the downside by it is that the documentations are very bad. So you should consider buying some books to learn it the most efficient way.


Before you didn’t implemented Firebase into your project you shouldn’t worry to much about the Frontend now since you need to understand both sides.

But to answer the Frontend question you could do it like this.

HTML:

<ion-button (click)="handleLike()">{{LikeValue}}</ion-button>
<ion-button (click)="handleDislike()">{{DislikeValue}}</ion-button>

TS:

export class YourClass{

LikeValue: number;
DislikeValue: number;

  constructor(){
  this.LikeValue = 0;
  this.DislikeValue = 0;
  }

  handleLike(){
   this.LikeValue++;
  }
  handleDislike(){
   this.DislikeValue++;
  }
}

Now your counters should raise as you click the buttons.

3 Likes

Thank you for your time <3 Now I just need to do it in realtime, I’ll test your code and thank you again

2 Likes