Format/unformat Ember.js computed properties with accounting.js
App = Ember.Application.create();
App.IndexController = Ember.ObjectController.extend({
amount: 100,
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')
});
Demo JS Bin.
Written by Chris Moore
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Emberjs
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#