小编aa_*_*mon的帖子

backbone.js和/或knockout.js中的AngularJS示例

我正在比较这些框架,以便在客户端进行一些计算.我真的很喜欢AngularJS网站上的例子.我想知道网站上的任何backbone.js或knockout.js专家是否会在各自的框架中重新创建该示例.

这是JSFiddle.

小提琴代码:

<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>
Run Code Online (Sandbox Code Playgroud)

<!-- 
  Workaround for jsfiddle to 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 …
Run Code Online (Sandbox Code Playgroud)

javascript-framework backbone.js angularjs knockout.js

9
推荐指数
2
解决办法
7985
查看次数