Ionic3-star-ratting - identifying who sent the value

#1

I have 3 ionic3-star-rating objects in a view, according to the manual I need to use the Events to receive the rating values ​​in the controller. How do I differentiate which object triggered the event? Because of the way an event is placed in the manual, it modifies the rating value of the three objects. The manual used is

events.subscribe('star-rating:changed', (starRating) => {console.log(starRating)});

#2

Ok, I have attached a click event on rating tags in the html file. When the user clicks, I noticed that star-rating:changed event fires before the click event. So, we store the rating in an instance variable and attach a click event to each rating tag and then send the type of rating element clicked as it’s parameter and set the values accordingly.

Demo: https://stackblitz.com/edit/ionic3-star-rating-zd9ax3

Look at About Page there(both html and ts file).

1 Like
#3

Cool Vivek! The code is very simple. Thanks for the feedback.

1 Like