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. linux - python 安装 Anaconda 环境变量问题请教2. mysql插入文本如果是个sql语句就报错了3. javascript - 使用vue-cli有个报错ERR_INCOMPLETE_CHUNKED_ENCODING4. python中merge后文件莫名变得非常大5. mysql - SQL添加记录的数据来源于同一个表6. html5 - 请问一下写H5的时候 你们都是兼容那些手机7. python3.x - python多线程如何修改数据?8. mysql连表排序9. css3 - 没明白盒子的height随width的变化这段css是怎样实现的?10. mysql sql where id in(25,12,87) 结果集如何用按照 25 12 87排序?

网公网安备