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. android - NavigationView 的侧滑菜单中如何保存新增项(通过程序添加)2. tp5 不同控制器中的变量调用问题3. 微信小程序可以用gulp,webpack吗?4. mysql服务无法启动1067错误,谁知道正确的解决方法?5. ueditor上传服务器提示后端配置项没有正常加载,求助!!!!!6. python - 为什么正常输出中文没有乱码,zip函数之后出现中文编程unicode编码的问题,我是遍历输出的啊。7. 老师 我是一个没有学过php语言的准毕业生 我希望您能帮我一下8. 这段代码既不提示错误也看不到结果,请老师明示错在哪里,谢谢!9. php7.3.4中怎么开启pdo驱动10. 提示语法错误语法错误: unexpected ’abstract’ (T_ABSTRACT)
