国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

angular.js - 怎么用Angularjs 來實現(xiàn)如圖

瀏覽:175日期:2024-10-13 18:48:21

問題描述

angular.js - 怎么用Angularjs 來實現(xiàn)如圖

每一行作為一個訂單商品詳情選擇商品填充商品名稱,價格數(shù)量默認為1,價格和數(shù)量可以手動修改,總價不能修改 總價=數(shù)量*單價;

怎么綁定這個每一行的model啊

問題解答

回答1:

寫了一個sample做參考:

<body ng-app='orderSum'> <table ng-controller='orderController'><thead> <tr><th>序號</th><th>數(shù)量</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

相關(guān)文章:
主站蜘蛛池模板: 和平县| 准格尔旗| 五原县| 蕲春县| 太保市| 新乡县| 新郑市| 迁西县| 永城市| 庐江县| 白朗县| 阿巴嘎旗| 屯昌县| 麦盖提县| 万载县| 凯里市| 吴江市| 当阳市| 汕尾市| 丰县| 泰兴市| 临洮县| 拉孜县| 新丰县| 丰镇市| 保亭| 平乐县| 屯留县| 永川市| 友谊县| 昌平区| 罗山县| 富顺县| 伊宁市| 黄山市| 巴塘县| 洛阳市| 龙游县| 清河县| 蚌埠市| 临漳县|