angular.js - 怎么用Angularjs 来实现如图
问题描述
每一行作为一个订单商品详情选择商品填充商品名称,价格数量默认为1,价格和数量可以手动修改,总价不能修改 总价=数量*单价;
怎么绑定这个每一行的model啊
问题解答
回答1:写了一个sample做参考:
<body ng-app='orderSum'> <table ng-controller='orderController'><thead> <tr><th>序号</th><th>数量</th><th>单价</th><th>总价</th> </tr></thead><tbody ng-repeat='order in orders track by $index'> <tr><td>{{ $index+1 }}</td><td><input ng-model='order.count'></td><td><input ng-model='order.price'></td><td><input readonly='true' value='{{ order.count * order.price }}'></td> </tr></tbody> </table> <script> var myApp = angular.module('orderSum',[]); myApp.controller('orderController',[’$scope’,function($scope){$scope.orders=[];$scope.orders.length=10; }]); </script></body>回答2:
ng-repeat + array.push({id:1,name:’’,price:0,num:0})
ng-repeat=’x in array’
ng-model=’x.num’
ng-model=’x.price’
ng-bind=’x.num * x.price’
回答3:ngRepeat
相关文章:
1. angular.js - vue/react 渲染内容抖动2. angular.js - react的redux和vue的vuex,angular呢3. javascript - 我写的href跳转地址不是百度,为什么在有的机型上跳转到百度了,有的机型跳转正确4. python - beautifulSoup4 .select(’.bnrName’) 取不到到 text 文字5. python socket 如何接收tcp/ip byte 格式的数据?6. html - node-module文件有两个在我的项目文件里7. angular.js - webstorm angular 语法没有错误,但有红色波浪线警告?8. html - 自学php 遇到代码不执行直接在网页上显示 望各位大神不吝赐教9. 一种简单的解决方案,用于检查Web服务器上是否存在文件(迅速)10. 与远程浏览器通信时出错。它可能已经死了。Selenium Web驱动程序
