Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
backbone.js和/或knockout.js中的AngularJS示例_Angularjs_Backbone.js_Knockout.js_Javascript Framework - Fatal编程技术网

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

backbone.js和/或knockout.js中的AngularJS示例,angularjs,backbone.js,knockout.js,javascript-framework,Angularjs,Backbone.js,Knockout.js,Javascript Framework,我正在比较这些框架,以便在客户端进行一些计算。我真的很喜欢网站上的例子。我想知道该站点上的backbone.js或knockout.js专家是否会在各自的框架中重新创建该示例 这是它的基本原理 小提琴的代码: <table ng:init="invoice= {items:[{qty:10, description:'gadget', cost:9.95}]}"> <tr> <th>Qty</th> <th>Desc

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

这是它的基本原理

小提琴的代码:

<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>

数量
描述
成本
全部的
{{item.qty*item.cost | currency}}
[]
总数:
{{invoice.items.$sum('qty*cost')| currency}


表th{
字体大小:粗体;
}
表td{
填充:0.3em;
}

这里是击倒JS的地方>

我可能有偏见,但它比棱角/主干更具结构性

如果你有任何问题,请告诉我


这里有一些NaN检查,我想你可以自己做。

还可以看看,它显示了一个用所有流行框架编写的标准TODO应用程序。

太快了,谢谢。我没有提到这一点,因为angular示例对我(一个真正的新手程序员)来说很有意义,我可以比较框架并选择一个作为开始。再次感谢一个领域,在这个领域中,击倒非常松散的脊梁或棱角是验证,在你的例子中,你也没有。这是真的。我通常使用jqueryvalidate插件和knockoutjs一起进行验证。fiddle无法加载(在Chrome中:“ko未定义”),IMHO knockout也太多了verbose@nEEbz你应该认真地试一下。。代码的结构和简洁性非常明显..来自backbone.js社区的任何人都想试一试。我会非常感激的。
<!-- 
  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;
}