title: Format knockout observable with commas and/or decimal places within html data binding, NOT in viewmodel
body: <p>I've seen RP Niemeyer's answer here: <a href="https://stackoverflow.com/questions/7704268/formatting-rules-for-numbers-in-knockoutjs">Formatting rules for numbers in KnockoutJS</a> but it doesn't seem to fit my situation.</p>
  
  <p>My viewmodel is tightly bound with breeze entities for a start, so I cannot easily mess with the individual table fields.  There are c. 40 fields that contain numerical impact calculation results, often to 9 or 10 decimal places. It is essential that the raw result is left untouched in the viewmodel.</p>
  
  <p>RP Niemeyer's "extend" based solution seems to suit more a situation where the observable is manually created. I'd like to be able to do the formatting within the html data-bind itself as this allows me to leave things untouched in the database and just limit the display of the calculation to 3 or 4 decimal places.</p>
  
  <p>I'd like to be able to do:</p>
  
  <pre><code>&lt;div data-bind="text: myValue, precision: 1"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>using the extend model such as this if possible?</p>
  
  <pre><code>ko.extenders.numeric = function(target, precision) {
      var result = target;
  
      result.formatted = ko.dependentObservable({
          read: function() {
             return target().toFixed(precision); 
          },
          write: target 
      });
  
      return result.formatted;
  };
  </code></pre>
  
  <p>but as it is, this currently doesn't work so I'm probably missing something really obvious.</p>