andrucz / ionic2-rating

:star: Angular star rating bar. Built for Ionic 2+.
MIT License
178 stars 62 forks source link

Can I do a loop? #39

Closed davidcm86 closed 6 years ago

davidcm86 commented 6 years ago

Hello again andrucz!

First of all, sorry if my question is a question from newbie in angular/ionic, because I am. I want to do a loop with your module, but it does not work for me, because here [(ngModel)]="rate" it's like that only works once and only could receive this.rate once from component. Is that true or there is other way?

I have an array with several rating.

Thank a lot!!

andrucz commented 6 years ago

Hello @davidcm86 In this case, you need one ngModel variable for each rating component.

<rating *ngFor="let item of items" [(ngModel)]="item.rate" ...>, for example

andrucz commented 6 years ago

Using an array of ratings:

<rating *ngFor="let rate of rates; let i = index" [(ngModel)]="rates[i]" ...>

davidcm86 commented 6 years ago

OMG, I did that without item, only rate....my mistake. Sorry about that. Thank a lot!