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. javascript - js一個(gè)call和apply的問(wèn)題?2. 老師,請(qǐng)問(wèn)我打開(kāi)browsersync出現(xiàn)這個(gè)問(wèn)題怎么解決啊?3. java - ssm整合 表現(xiàn)層訪問(wèn)時(shí)報(bào)錯(cuò)。。4. mysql - 數(shù)據(jù)庫(kù)為什么需要鎖機(jī)制?5. javascript - js 修改表格元素的,可以用DOM操作實(shí)現(xiàn)嗎?6. node.js - JavaScript的一個(gè)不能理解的地方7. javascript - 給某個(gè)類添加一個(gè)偽類,這個(gè)類有click事件,現(xiàn)在我點(diǎn)擊偽類也觸發(fā)了click事件8. javascript - JS使用ele.style.backgoundImage = ’’ =’none’取消背景圖片都無(wú)效9. javascript - js 萬(wàn)物皆對(duì)象的問(wèn)題10. python - xpath提取網(wǎng)頁(yè)路徑?jīng)]問(wèn)題,但是缺失內(nèi)容?
