AngularJS example in backbone.js and/or knockout.js -
i'm comparing these frameworks calculations on client side. liked example on angularjs site. wondering if of backbone.js or knockout.js experts on site please recreate example in respective frameworks.
here jsfiddle it.
code of fiddle:
<table ng:init="invoice= {items:[{qty:10, description:'gadget', cost:9.95}]}"> <tr> <th>qty</th> <th>description</th> <th>cost</th> <th>total</th> <th></th> </tr> <tr ng:repeat="item in invoice.items"> <td><input name="item.qty" value="1" size="4" ng:required ng:validate="integer"></td> <td><input name="item.description"></td> <td><input name="item.cost" value="0.00" ng:required ng:validate="number" size="6"></td> <td>{{item.qty * item.cost | currency}}</td> <td>[<a href ng:click="invoice.items.$remove(item)">x</a>]</td> </tr> <tr> <td><a href ng:click="invoice.items.$add()">add item</a></td> <td></td> <th>total:</th> <td>{{invoice.items.$sum('qty*cost') | currency}}</td> </tr> </table>
<!-- workaround jsfiddle pass in ng:autobind http://doc.jsfiddle.net/basic/introduction.html#css --> <script src="http://code.angularjs.org/angular-0.9.10.min.js" ng:autobind></script> <style> table th { font-weight: bold; } table td { padding: 0.3em; }
here go knockoutjs >
http://jsfiddle.net/neebz/ybwzj/
i might biased it's lot more structural angular/backbone.
if have questions, let me know.
there nan checks think take yourself.
Comments
Post a Comment