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. mysql主从,从库锁表会导致复制阻塞吗?2. javascript - ES5的闭包用ES6怎么实现3. html - 特殊样式按钮 点击按下去要有凹下和弹起的效果4. 关于Java引用传递的一个困惑?5. javascript - 小米浏览器中,图片导致fixed定位的元素无法显示6. java - yuicompressor-maven-plugin 合并可用却不压缩, 哪配置不对?7. mysql - 我用SQL语句 更新 行的时候,发现全部 中文都被清空了,请问怎么解决?8. javascript - 为什么!function foo(){}返回false,!function foo(){}()返回true?9. word-wrap该如何使用?10. update方法不能更新字段值为0的数据
