andrucz / ionic2-rating

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

Starting with x stars painted #32

Closed joancolmenerodev closed 6 years ago

joancolmenerodev commented 6 years ago

Is there any way to start with for example 3 of 5 stars painteds?

andrucz commented 6 years ago

Hey @joancolmenerodev. Sorry for the delay. Yes, keep in mind that the component presentation reflects ngModel value.

Take for example <rating [(ngModel)]="rate" ... />. If you assign 3 to rate variable, the component will be shown with 3 stars painted.

wyklif commented 6 years ago

What about 3.5? as in three and a half stars painted?

saidllamasm commented 6 years ago

Hello! I have the same concern, in my case, the most optimal would be to assign the rantig from the view, example: `<div class="single-university" *ngFor="let University of Universities">

{{University.name}}
        </div>`

Is this possible to do?

saidllamasm commented 6 years ago

I have already solved it with the help of the following comment https://github.com/andrucz/ionic2-rating/issues/17#issuecomment-294292545), Annex source code example: Universities.ts this.nearbyUniversities = [ { imgsrc : "http://becas-mexico.mx/wp-content/uploads/2017/10/becas-mexico-itcg-2017-2018.jpg", name :"Instituto Tecnológico de Ciudad Guzmán", rate : 2, id:"3" }, { imgsrc: "https://cdn-az.allevents.in/banners/2ec9e7fae6b19132288b69c8f1d9e5c9", name :"Universidad Pedagógica Nacional de Ciudad Guzmán", rate : 4, id:"4" }, { imgsrc: "https://cdn-az.allevents.in/banners/2ec9e7fae6b19132288b69c8f1d9e5c9", name :"Universidad Pedagógica Nacional de Ciudad Guzmán", rate : 2.5, id:"4" } ]; Universities.html `

<div class="single-university" *ngFor="let nearbyUniversity of nearbyUniversities">

{{nearbyUniversity.name}}
        </div>
    </div>`