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>
<!--
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;
}
I'm comparing these frameworks to do some calculations on the client side. I really liked the example on the AngularJS site. I was wondering if any of the backbone.js or knockout.js experts on the site would please recreate that example in their respective frameworks.
Here is the JSFiddle for it.
Code of the 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 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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另请查看 https://github.com/addyosmani/todomvc,其中显示了用所有流行框架编写的标准 TODO 应用程序。
Also have a look https://github.com/addyosmani/todomvc which show a standard TODO app written in all popular frameworks.
在这里,您可以进行淘汰赛>
http://jsfiddle.net/neebz/YbwzJ/
我可能有偏见,但它更具结构性比角/骨干。
如果您有任何疑问,请告诉我。
我认为您可以自己进行一些 NaN 检查。
Here you go for knockoutjs >
http://jsfiddle.net/neebz/YbwzJ/
I might be biased but it's a lot more structural than angular/backbone.
If you have any questions, let me know.
There are some NaN checks which I think you could take yourself.