Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import Ember from 'ember';
  2.  
  3. export default Ember.Controller.extend({
  4. appName:'Ember Twiddle',
  5. name: "",
  6. balance: 0,
  7.  
  8. totalBalanceInCents: function() {
  9. var totalBalance = 0.0;
  10. this.model.forEach(function(account, index) {
  11. totalBalance += account.get('balance_in_cents');
  12. });
  13. return totalBalance;
  14. }.property('model.@each.balance_in_cents'),
  15. totalBalance: function() {
  16. return this.get('totalBalanceInCents') / 100;
  17. }.property('totalBalanceInCents'),
  18.  
  19. actions: {
  20. createAccount() {
  21. Ember.debug("createAction triggered");
  22. this.store.createRecord('account', {
  23. name: this.get('name'),
  24. balance: this.get('balance')
  25. });
  26. }
  27. }
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement