Guest User

Untitled

a guest
Dec 16th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'app-root',
  4. template: `
  5. <rating></rating>
  6. `,
  7. styleUrls: ['./app.component.css']
  8. })
  9.  
  10. export class AppComponent {
  11. }
  12.  
  13. import { Component } from '@angular/core';
  14.  
  15. @Component({
  16. selector: 'rating',
  17. template: `
  18. <i class="star"
  19. [class.star-empty-icon]="rating < 1"
  20. [class.star-full-icon]="rating >= 1"
  21. (click)="onClick(1)">
  22. </i>
  23. <i class="star"
  24. [class.star-empty-icon]="rating < 2"
  25. [class.star-full-icon]="rating >= 2"
  26. (click)="onClick(2)">
  27. </i>
  28. `
  29. })
  30. export class RatingComponent{
  31. rating = 0;
  32. onClick(ratingValue){
  33. this.rating = ratingValue;
  34. }
  35. }
  36.  
  37. .star.star-full-icon{
  38. content:'X';
  39. }
  40. .star.star-empty-icon{
  41. content:'O';
  42. }
Add Comment
Please, Sign In to add comment