在項(xiàng)目中遇到表單似的頁面,需要進(jìn)行增加一行和減少一行的操作,例如:
從策劃到設(shè)計(jì)制作,每一步都追求做到細(xì)膩,制作可持續(xù)發(fā)展的企業(yè)網(wǎng)站。為客戶提供網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、網(wǎng)站策劃、網(wǎng)頁設(shè)計(jì)、域名申請(qǐng)、網(wǎng)頁空間、網(wǎng)絡(luò)營(yíng)銷、VI設(shè)計(jì)、 網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。為客戶提供更好的一站式互聯(lián)網(wǎng)解決方案,以客戶的口碑塑造優(yōu)易品牌,攜手廣大客戶,共同發(fā)展進(jìn)步。
要實(shí)現(xiàn)可以選中商品,以及對(duì)商品的信息列表進(jìn)行顯示與否的操作
html代碼如下:
<div class="chanpinxiangqing"> <div class="item item-divider">產(chǎn)品明細(xì)</div> <div class="chanpinxiangqing" ng-repeat="master in masters"> <div class="item item-divider"> <div class="" ng-click="selectorOne($index)" > <div class="chioceHook sPround"> <div class="ion-checkmark-round ng-hide" ng-show="master.checked" ></div> </div> <span >產(chǎn)品</span> </div> <div ng-click="upOrdown($index);" ng-class="{true:'up',false:'upDown'}[master.updown]"></div> </div> <ul class="rzInfo" ng-show="master.up"> <li class="row"> <span class="col-xs-5"><!--產(chǎn)品類型-->{{master.chanpinType}}</span> <select class="" ng-model="myselectType" mobiscroll-select="settings" mobiscroll-instance="demo"> <option value="0">請(qǐng)選擇</option> <option value="1">中藥</option> <option value="2">西藥</option> </select> </li> <li class="row"> <span class="col-xs-5"><!--產(chǎn)品名稱-->{{master.chanpinName}}</span> <select class="" ng-model="myselectName" placeholder="請(qǐng)選擇" mobiscroll-select="settings" mobiscroll-instance="demo"> <option value="0">請(qǐng)選擇</option> <option value="1">注射劑</option> <option value="2">麻醉劑</option> </select> </li> <li class="row"> <span class="col-xs-5"><!--規(guī)格-->{{master.guige}}</span> <select class="" ng-model="myselectGuige" placeholder="請(qǐng)選擇" mobiscroll-select="settings" mobiscroll-instance="demo"> <option value="0">請(qǐng)選擇</option> <option value="1">10ml</option> <option value="2">20ml</option> </select> </li> <li class="row"> <span class="col-xs-5"><!--單位-->{{master.danwei}}</span> <input type="text" name="" class="col-xs-8" value="" /> </li> <li class="row"> <span class="col-xs-5"><!--數(shù)量-->{{master.num}}</span> <!--<b class="" contenteditable="true" ng-model="dataclean" ></b>--> <input type="text" name="" class="col-xs-8" value="" /> </li> <li class="row"> <span class="col-xs-5"><!--單價(jià)(元)-->{{master.price}}</span> <input type="text" name="" class="col-xs-8" value="" /> </li> <li class="row"> <span class="col-xs-5"><!--總價(jià)-->{{master.total}}</span> <input type="text" name="" readonly class="col-xs-8" value="" /> </li> </ul> </div> </div> <div class="" ><span>合計(jì)發(fā)貨總額:</span></div> <div class=""> <div class="btnadd" ng-click="add()">增加</div> <div class="btndel" ng-click="delete()">刪除</div> </div>
js代碼:
//控制器及服務(wù)等 .controller('fhShenQingAddCtrl', function($scope, CONFIG, $ionicSlideBoxDelegate, $rootScope, $http, $ionicPopup, faHuoService, $timeout, $window, loading, tool) { //產(chǎn)品下的類型名稱及規(guī)格的選擇彈窗設(shè)置 $scope.settings = { theme: 'mobiscroll', lang: 'zh', display: 'center', cancelText: '取消', setText: '確定', onBeforeClose: function(event, inst) { if(event.button == "set") { $scope.startdate = event.valueText;//獲取選擇日期 console.log($scope.startdate) } else if(event.button == "cancel") { console.log("取消") } } }; //增加 $scope.masters= [{'chanpinType':'產(chǎn)品類型', 'chanpinName':'產(chǎn)品名稱', 'guige':'規(guī)格', 'danwei':'單位', 'num':'數(shù)量', 'price':'單價(jià)(元)', 'total':'總價(jià)', 'checked':'true',//選中切換 'updown':'true',//下拉內(nèi)容顯示切換 'up':'true'//箭頭上下切換 }]; $scope.add = function() { $scope.cope={'chanpinType':'產(chǎn)品類型', 'chanpinName':'產(chǎn)品名稱', 'guige':'規(guī)格', 'danwei':'單位', 'num':'數(shù)量', 'price':'單價(jià)(元)', 'total':'總價(jià)', 'checked':'true', //選中切換 'updown':'true', //下拉內(nèi)容顯示切換 'up':'true' //箭頭上下切換 }; var bb = angular.copy($scope.cope); $scope.masters.push(bb) console.log($scope.masters) }; //刪除 $scope.delete = function() { var arr = []; angular.forEach($scope.masters,function(item,index){ if(!item.checked){ arr.push(item); } }) //console.log(arr) $scope.masters = arr; }; //切換箭頭的上下指向這里寫代碼片 $scope.upOrdown = function(rowNumber){ console.log($scope.masters[rowNumber].updown) $scope.masters[rowNumber].up = !$scope.masters[rowNumber].up; $scope.masters[rowNumber].updown=!$scope.masters[rowNumber].updown; }; //某一行選中 $scope.selectorOne = function(rowNumber) { console.log($scope.masters[rowNumber].checked) $scope.masters[rowNumber].checked = !$scope.masters[rowNumber].checked; }; })
完成的效果為:
點(diǎn)擊前
點(diǎn)擊后
以上所述是小編給大家介紹的ionic中列表項(xiàng)增加和刪除的實(shí)現(xiàn)方法,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)創(chuàng)新互聯(lián)網(wǎng)站的支持!
網(wǎng)頁題目:ionic中列表項(xiàng)增加和刪除的實(shí)現(xiàn)方法
瀏覽地址:http://jinyejixie.com/article44/ggijee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、標(biāo)簽優(yōu)化、移動(dòng)網(wǎng)站建設(shè)、外貿(mào)建站、、網(wǎng)站收錄
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)