Guest User

Untitled

a guest
Mar 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. orders = [
  2. {id_service: "1", id_empresa: "9", nome_service: "Servico 01", qtd: "0", checkup: "false", price_service : "250"},
  3.  
  4. {id_service: "2", id_empresa: "9", nome_service: "Servico 02", qtd: "0", checkup: "false" price_service : "300"},
  5.  
  6. {id_service: "3", id_empresa: "9", nome_service: "Servico 03", qtd: "0", checkup: "false" price_service : "400"}
  7. ]
  8.  
  9. calc(i) {
  10. let obj = JSON.parse(this.orders[i].price_service);
  11.  
  12.  
  13. if (this.orders[i].qtd == 0) {
  14. this.result.push(obj);
  15. this.orders[i].qtd = 1;
  16. }
  17. else {
  18. this.result.splice(i, 1);
  19. this.orders[i].qtd = 0;
  20. }
  21. this.result.reduce(function (a, b) {
  22. return a + b['obj'];
  23. }, 0);
  24.  
  25. }
  26.  
  27. <div *ngFor="let item of orders; let i = index; ">
  28. <ion-item>
  29. <ion-label class="title">{{item.nome_service}}
  30. <span>{{item.price_service}}</span>
  31. </ion-label>
  32. <ion-checkbox (click)="calc(i)" checked="{{item.checkup}}" color="green"></ion-checkbox>
  33. </ion-item>
  34. <p>{{result}}</p>
  35. </div>
Add Comment
Please, Sign In to add comment