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. 为什么我ping不通我的docker容器呢???2. java - xml 传输数据如何处理更好3. javascript - h5上的手机号默认没有识别4. mac里的docker如何命令行开启呢?5. mysql - 要取出数据库中按某字段排序后的前10,20,30条数据要怎么做?6. mysql配置没问题,但不显示中文;7. javascript - 用原生的js获取body和用jquery获取body的的margin值为什么不一样?8. Python Selenium WebDriver如何刷新当前页面9. pycharm运行python3.6突然出现R6034问题,请问如何处理?10. 用tp5框架写sql语句

网公网安备