ContributorsLast modified on: Mar 25, 2016
farhan687

Problem

You’re displaying formatted values in user inputs as currency with Accounting.js and need to remove the decoration to set the attributes upstream.

Solution

Make use of the computed property’s setter to remove the display formatting and set the property to the proper value.

formattedAmount: function(key, value) {
  if (arguments.length > 1) {
    // setter
    var cleanAmount = accounting.unformat(value);
    this.set('amount', cleanAmount);
  }

  return accounting.formatMoney(this.get('amount'));
}.property('amount')

Example

JS Bin