Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. @Component({
  2. selector: 'my-app',
  3. template: `
  4. <input type="checkbox" (click)="getNight()">Night
  5. <input type="checkbox" (click)="getDay()">Day
  6. <input type="checkbox">Uncheck
  7. <br><br>
  8. <table>
  9. <tr *ngFor="let task of tasks">
  10. <td>{{task.chkBoxImageUrl}}</td>
  11. <td>{{task.id}}</td>
  12. <td>{{task.val}}</td>
  13. </tr>
  14. </table>
  15. `,
  16. })
  17. export class App {
  18. tasks: Array<{chkBoxImageUrl: string, id: string, val: string,
  19. checked:boolean}> = [
  20. {chkBoxImageUrl: "http1", id: "item1", val: "Night", checked: false},
  21. {chkBoxImageUrl: "http2", id: "item2", val: "Day", checked: false},
  22. {chkBoxImageUrl: "http3", id: "item3", val: "Night", checked: false},
  23. {chkBoxImageUrl: "http4", id: "item4", val: "Day", checked: false},
  24. {chkBoxImageUrl: "http4", id: "item4", val: "Morning", checked: false},
  25. {chkBoxImageUrl: "http4", id: "item4", val: "Evening", checked: false}
  26. ];
  27.  
  28. getNight() {
  29. console.log(this.tasks[2].val); // Night
  30. // return this.tasks.filter(obj => obj.checked).map(obj => obj.val);
  31. if(this.tasks.val == 'Night') {
  32. return this.tasks.filter(obj => obj.checked).map(obj => obj.val == 'Night');
  33. } else {
  34. console.log('666666');
  35. }
  36. };
  37. getDay() {
  38. return this.tasks.filter(obj => obj.checked).map(obj => obj.val);
  39. };
  40. getCheckedCount(){
  41. return this.getCheckedValues().length;
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement