angular.js - 怎么用Angularjs 來(lái)實(shí)現(xiàn)如圖
問(wèn)題描述
每一行作為一個(gè)訂單商品詳情選擇商品填充商品名稱,價(jià)格數(shù)量默認(rèn)為1,價(jià)格和數(shù)量可以手動(dòng)修改,總價(jià)不能修改 總價(jià)=數(shù)量*單價(jià);
怎么綁定這個(gè)每一行的model啊
問(wèn)題解答
回答1:寫(xiě)了一個(gè)sample做參考:
<body ng-app='orderSum'> <table ng-controller='orderController'><thead> <tr><th>序號(hào)</th><th>數(shù)量</th><th>單價(jià)</th><th>總價(jià)</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
相關(guān)文章:
1. 如何解決docker宿主機(jī)無(wú)法訪問(wèn)容器中的服務(wù)?2. 頁(yè)面用CSS3的scale屬性進(jìn)行了縮放,圖片模糊解決不了,那么字體能否讓它們不模糊呢?3. 請(qǐng)問(wèn)關(guān)于 Java static 變量的問(wèn)題?4. 跨類(lèi)調(diào)用后,找不到方法5. javascript - 微信IOS頁(yè)面中input type=number輸入數(shù)字無(wú)法顯示,安卓顯示正常6. 淺談vue生命周期共有幾個(gè)階段?分別是什么?7. node.js - vue-cli webpack express配置服務(wù)端路由規(guī)則8. $( "html" ).parent()方法返回一個(gè)包含document的集合,而$( "html" ).parents()返回一個(gè)空集合 哪位大神來(lái)解釋下?9. ios - Crash Log 里關(guān)于微信SDK的問(wèn)題10. javascript - hash為什么可以做路由跳轉(zhuǎn),不會(huì)刷新頁(yè)面
