AngularJS ng-repeat遍歷輸出的用法,最近需要用,就順便發(fā)到隨筆上了
<!doctype html> <html> <head> <meta charset="utf-8"> <title>ng-repeat directive</title> </head> <body ng-app="myApp"> <table ng-controller="CartController"> <caption>我的購物車</caption> <tr> <th>序號</th> <th>商品</th> <th>單價</th> <th>數量</th> <th>金額</th> <th>操作</th> </tr> <tr ng-repeat="item in items"> <td>{{$index + 1}}</td> <td>{{item.name}}</td> <td>{{item.price | currency}}</td> <td><input ng-model="item.quantity"></td> <td>{{item.quantity * item.price | currency}}</td> <td> <button ng-click="remove($index)">Remove</button> </td> </tr> </table> <script src="js/angular-1.3.0.14/angular.min.js"></script> <script> var app = angular.module('myApp', []); app.controller('CartController',function($scope){ $scope.items = [ {name: "蘋果 iPhone7", quantity: 1, price: 5088.00}, {name: "榮耀Magic", quantity: 1, price: 3699.00}, {name: "vivo X9", quantity: 2, price: 2798.00} ]; //$index包含了ng-repeat過程中的循環(huán)計數 $scope.remove = function (index) { $scope.items.splice(index, 1); } }) </script> </body> </html>
另外有需要云服務器可以了解下創(chuàng)新互聯建站jinyejixie.com,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
當前名稱:AngularJSng-repeat遍歷輸出的用法-創(chuàng)新互聯
文章出自:http://jinyejixie.com/article20/ddcgjo.html
成都網站建設公司_創(chuàng)新互聯,為您提供移動網站建設、軟件開發(fā)、App開發(fā)、自適應網站、虛擬主機、網站制作
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯