2011-03-07 93 views
9

我正在比較這些框架在客戶端執行一些計算。我非常喜歡AngularJS網站上的示例。我想知道網站上的任何backbone.js或knockout.js專家是否會在各自的框架中重新創建該示例。backbone.js中的AngularJS示例和/或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> 

<!-- 
    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 { 
    padding: 0.3em; 
} 
+0

任何來自backbone.js社區的人都想給它一個機會。會真的很感激它。 – 2011-03-22 00:24:54

回答

4

在這裏,你去knockoutjs>

http://jsfiddle.net/neebz/YbwzJ/

我可能有偏差,但它的很多超過結構角/骨幹。

如果您有任何問題,請告訴我。

有一些NaN檢查,我認爲你可以把自己。

+0

很快,謝謝。我沒有提到,因爲角度的例子對我來說很有意義(一個真正的新手程序員),我可以比較框架並選擇一個開始。再次感謝 – 2011-03-07 19:59:07

+0

其中一個區域,其中淘汰賽確實鬆散骨幹或角度驗證,在你的例子中,你也沒有它。 – sha1dy 2011-05-12 12:44:26

+0

這是真的。我通常使用jQuery驗證插件進行驗證以及knockoutjs。 – neebz 2011-05-12 15:21:14