Ionic Count likes


#1

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


#2

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


#3

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…


#4

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 ?


#5

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:


#6

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.


#7

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