Guest User

Untitled

a guest
Sep 26th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. export class RatingsComponent {
  2. ...
  3. set rating(v) {
  4. this._rating = v;
  5.  
  6. // triggers DOM update
  7. this.updateRatings();
  8. }
  9.  
  10. get rating() {
  11. return this._rating;
  12. }
  13.  
  14. updateRatings() {
  15. this.elements.forEach((element, index) => {
  16. if (index < this.rating) {
  17. element.classList.remove('outline');
  18. element.classList.add('solid');
  19. } else {
  20. element.classList.remove('solid');
  21. element.classList.add('outline');
  22. }
  23. });
  24. }
  25. }
Add Comment
Please, Sign In to add comment