Skip to content

09.0.0 Use a Component For Rating

Patrick Baselier edited this page Oct 13, 2015 · 1 revision

What you will learn

  • Create a component for rating

Before you start

See the installation instructions. Use tag 9.0.0.

Add a Component

  • Open frontend/app/templates/products/show.hbs and within the {{#each model.reviews as |review|}} helper, replace all the <span class='glyphicon... tags with {{star-rating starCount=review.rating}}.
  • Inspect the error shown in the Console tab in the browser. Ember is missing the star-rating component, so let's create this.
  • In the terminal, from the frontend folder enter ember g component star-rating.
  • Open app/templates/components/star-rating.hbs and replace the content with the code from this gist from star-rating.hbs.
  • Open app/components/star-rating.js and replace the content with the code from this gist from star-rating.js.