I have the below page working pretty well (I've cut out some other fields and styling to keep the sample that I post here smallish). I'd like the Premium line in the table (line 17) to format as currency (USD). What's the best way of doing this?
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <div class="datagrid" > <table > <thead> <tr> <th>Location Name</th> <th>Location Total</th> </tr> </thead> <tbody data-bind="foreach: { data: Locations, as: 'location' }"> <tr> <td><span data-bind="text: location.LocationName" /> </td> <td><span data-bind="text: location.Premium" /> </td> </tr> </tbody> </table> </div> <script> $(document).ready(function () { var appViewModel // AppViewModel function AppViewModel() { this.Locations = ko.observable([]); } var appViewModel = new AppViewModel(); ko.applyBindings(appViewModel); $.getJSON("http://waltweb01:85/LTCEPLWS/LTCJSON.svc/getLTCWithIDs/4", function (data) { incomingData = data; appViewModel.Locations(data.getLTCWithIDsResult.Locations); }); }); </script> </asp:Content>
Premiuman ko.observable? If you then you need to write<span data-bind="text: formatCurrency(location.Premium())>note the parens()afterPremium... jsfiddle.net/kks53