Code Monkey home page Code Monkey logo

Comments (9)

MurhafSousli avatar MurhafSousli commented on May 26, 2024 1

If the user has already voted then the component should be disabled, use [disabled] input in this case.

from ngx-bar-rating.

MurhafSousli avatar MurhafSousli commented on May 26, 2024 1

I think it is better to have an option to manually update the rate

from ngx-bar-rating.

Octavious avatar Octavious commented on May 26, 2024

Thank you

It will solve the issue if already voted.

Just a quick question, if he didn't vote, and I want to show the new rate (not the user vote itself), then I have to handle it in my model I guess.. Not through the component, correct?

May I suggest that in the future, the component gives back the original value and the vote rate value in the event [rateChange], it will make life much easier :)

Thanks for your reply

from ngx-bar-rating.

MurhafSousli avatar MurhafSousli commented on May 26, 2024

First, the rate value is bound to your service, when user rates, it update the rate value his rate and the output will emit, on that emit you should update the rate value of that model using your service

<bar-rating [rate]="model.rate" (rateChange)="updateRate(model.id, $event)"></bar-rating>
updateRate(id, value) {
   myService.updateModelRate(id, value);
}

When the model is updated it will update the component with the total rate.

from ngx-bar-rating.

Octavious avatar Octavious commented on May 26, 2024

i will do it that way

Thanks Murhaf

from ngx-bar-rating.

Octavious avatar Octavious commented on May 26, 2024

actually, i am trying to update the model to apply new rate, it seems it works only for the first time:
https://plnkr.co/edit/3GSfiO70Dq1Ghsn48cWw?p=preview

check the star rating

and sorry for annoying

from ngx-bar-rating.

MurhafSousli avatar MurhafSousli commented on May 26, 2024

@Octavious I forgot that this is already possible using the function update()
You can use @ViewChild() to get a reference of the rating component and update it manually
here is a live stackblitz

from ngx-bar-rating.

Octavious avatar Octavious commented on May 26, 2024

@MurhafSousli: i guess it is becoming to advanced for me :)

i have more than one component (doing ngfor to loop over them), and doing little search suggested that i need to use @ViewChildren, still, i dont seem to be able to get a handle to the particular one which fired the event.

from ngx-bar-rating.

Octavious avatar Octavious commented on May 26, 2024

Hello,

i have made a change in the component which i think will lead it to solve my issue:

if you have time, can you check it?

Regards

changedfiles.zip

from ngx-bar-rating.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.