Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>despite your question is qualified as just an AngularJs question I have a other suggestion to approach your desired effect with algo Angular Js but a little bit of Css trick.</p> <p>First I would get two <strong>5 star</strong> images one 'Empty' or gray and one 'Full' or yellow like so: <img src="https://i.stack.imgur.com/sGnY4.jpg" alt="Empty stars"></p> <p>Then I would create a <strong>div</strong> with the <strong>gray</strong> stars and a <strong>overlay div</strong> with the <strong>bright yellow</strong> ones. Both using <code>background-image</code> instead of regular <code>&lt;img&gt;</code> tags, doing this I would be able to change the width of the overlay div to achieve the amount of rating necessary.</p> <p><strong>Check out this <a href="http://jsfiddle.net/Xes4v/1/" rel="nofollow noreferrer">quick fiddle</a></strong> (I apologize for the poor images, it was what I could get from google images for a quick demo - play around with the width in the full-star div to see) </p> <p>First I would organize the Html as the following:</p> <pre><code>&lt;div class="star-rating"&gt; &lt;!-- The '|| 0' would prevent an undefined or null value on the Rating property --&gt; &lt;div class="full-star" style="width: {{Item.ItemDetails.Rating * 20 || 0}}%"&gt;&lt;/div&gt; &lt;div class="empty-star"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The width on the full-star will determine how much of the star would appear.</p> <p>With the following <strong>Css</strong>: </p> <pre><code>/* This is just an example instead of using &lt;img&gt; tags you can use background-image and achive half-star results */ .star-rating { position: relative; /* other styles to match preference */ } .full-star { position: absolute; z-index: 1; height: 100%; background-image: url('PATH_TO ~/Images/star.png'); /* other styles to match preference */ } .empty-star { width: 100%; height: 100%; background-image: url('PATH_TO ~/Images/star_gray.png'); /* other styles to match preference */ } </code></pre> <p>Cheers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload