最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Angular實(shí)現(xiàn)的table表格排序功能完整示例

 更新時(shí)間:2017年12月22日 11:08:51   作者:qq_41073714  
這篇文章主要介紹了Angular實(shí)現(xiàn)的table表格排序功能,結(jié)合完整實(shí)例形式分析了AngularJS表格排序所涉及的事件響應(yīng)、元素遍歷、屬性修改等相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Angular實(shí)現(xiàn)的table表格排序功能。分享給大家供大家參考,具體如下:

先來看看效果圖:

完整代碼如下:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>m.fzitv.net Angular表格排序</title>
    <style>
      table{
        border: 1px solid;
        text-align: center;
        width: 40%;
        height: 400px;
      }
      tr,td{
        border: 1px solid;
      }
      tr:nth-child(2n){
        background: gainsboro;
      }
    </style>
    <script type="text/javascript" src="js/angular.min.js" ></script>
    <script type="text/javascript" src="js/jquery-1.9.1.min.js" ></script>
    <script>
      var app=angular.module("MyApp",[]);
      app.controller("demoC",["$scope",function($scope){
        $scope.shop=[{ state1:false,id:9001,name:"iphoneX",username:"張三",tel:13525565588,price:8699,city:"北京",time:new Date('11-23 10:00:00'),state:"已發(fā)貨"},
        {state1:false,id:3007,name:"iphone6",username:"王紅",tel:18524565588,price:5635,city:"鄭州",time:new Date('11-23 11:38:20'),state:"已發(fā)貨"},
        {state1:false,id:5312,name:"iphone7",username:"趙小龍",tel:17545585598,price:6180,city:"北京",time:new Date('11-23 9:17:00'),state:"未發(fā)貨"},
        {state1:false,id:2132,name:"iphone8",username:"趙強(qiáng)",tel:17625565618,price:7190,city:"上海",time:new Date('11-23 10:40:00'),state:"未發(fā)貨"}
        ];
        $scope.ckAll=function(){
          for(var i in $scope.shop){
            $scope.shop[i].state1=$scope.ckall;
          }
        }
        $scope.del=function(){
            for(var i=0; i<$scope.shop.length; i++){
              if($scope.shop[i].state=="已發(fā)貨"&&$scope.shop[i].state){
                $scope.shop.splice(i,1);
                i--;
                }
                }
        }
        $scope.add=function(){
          var sname=$scope.sname;
          var susername=$scope.susername;
          var stel=$scope.stel;
          var sprice=$scope.sprice;
          var scity=$scope.scity;
          if(sname==undefined || sname==""){
            alert("用戶名不能為空");
            $("#s").css("border-color","red");
          }else if(susername==undefined || susername==""){
            alert("商品名不能為空");
            $("#y").css("border-color","red");
          }else if(stel==undefined || stel==""){
            alert("手機(jī)號(hào)不能為空");
            $("#t").css("border-color","red");
          }else if(sprice==undefined || sprice==""){
            alert("價(jià)格不能為空");
            $("#p").css("border-color","red");
          }else if(scity==undefined || scity==""){
            alert("城市必須選擇");
          }
          else{
            $scope.shop.push({name:sname,username:susername,tel:stel,price:sprice,city:scity})
            $scope.toto=false;
          }
        }
      }])
    </script>
  </head>
  <body ng-app="MyApp" ng-controller="demoC">
    <button ng-click="toto=true" style="background-color: greenyellow;">新增訂單</button>
    <button ng-click="del()" style="background-color: greenyellow;">批量刪除</button>
    <input type="text" placeholder="按商品名稱查詢" ng-model="selname" />
    <input type="text" placeholder="按手機(jī)號(hào)查詢" ng-model="seltel"/>
    <select ng-model="selstate">
      <option value="">按狀態(tài)查詢</option>
      <option value="已發(fā)貨">已發(fā)貨</option>
      <option value="未發(fā)貨">未發(fā)貨</option>
    </select>
    <table cellpadding="0px" cellspacing="0px">
      <tr style="background-color: gray;">
        <td><input type="checkbox" ng-model="ckall" ng-click="ckAll()"></td>
        <td>id<button ng-click="px='id';flag=!flag" style="background-color: greenyellow;">排序</button></td>
        <td>商品名</td>
        <td>用戶名</td>
        <td>手機(jī)號(hào)</td>
        <td>價(jià)格<button ng-click="px='price';flag=!flag" style="background-color: greenyellow;">排序</button></td>
        <td>城市</td>
        <td>下單時(shí)間<button ng-click="px='time';flag=!flag" style="background-color: greenyellow;">排序</button></td>
        <td>狀態(tài)</td>
      </tr>
      <tr ng-repeat="s in shop | filter:{name:selname} | filter:{tel:seltel} | filter:{state:selstate} | orderBy:px:flag ">
        <td><input type="checkbox" ng-model="s.state1"></td>
        <td>{{s.id}}</td>
        <td>{{s.name}}</td>
        <td>{{s.username}}</td>
        <td>{{s.tel}}</td>
        <td>{{s.price | currency:"¥"}}</td>
        <td>{{s.city}}</td>
        <td>{{s.time | date : 'MM-HH hh:dd:ss'}}</td>
        <td><span ng-show="s.state=='已發(fā)貨'" style="color: greenyellow;">{{s.state}}</span>
              <span ng-show="s.state=='未發(fā)貨'" style="color: yellow;"><a href="#" rel="external nofollow" ng-click="s.state='已發(fā)貨'">{{s.state}}</a></span></td>
      </tr>
    </table>
    <div style="margin-top: 50px; margin-left: 100px;">
      <form ng-show="toto">
        商品名:<input type="text" / ng-model="sname" id="s"><br /><br />
      用戶名:<input type="text" ng-model="susername"id="y"/><br /><br />
      手機(jī)號(hào):<input type="text" ng-model="stel" id="t"/><br /><br />
      價(jià)格為:<input type="text" ng-model="sprice" id="p"/><br /><br />
      城市:<select ng-model="scity">
        <option value="">--選擇城市--</option>
        <option value="北京">北京</option>
        <option value="上海">上海</option>
        <option value="鄭州">鄭州</option>
      </select><br /><br />
      <button ng-click="add()">保存</button>
      </form>
    </div>
  </body>
</html>

更多關(guān)于AngularJS相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《AngularJS指令操作技巧總結(jié)》、《AngularJS入門與進(jìn)階教程》及《AngularJS MVC架構(gòu)總結(jié)

希望本文所述對(duì)大家AngularJS程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 詳解Angular CLI + Electron 開發(fā)環(huán)境搭建

    詳解Angular CLI + Electron 開發(fā)環(huán)境搭建

    本篇文章主要介紹了Angular CLI + Electron 開發(fā)環(huán)境搭建,具有一定的參考價(jià)值,有興趣的可以了解一下
    2017-07-07
  • AngularJS內(nèi)置指令

    AngularJS內(nèi)置指令

    這篇文章主要詳細(xì)介紹了AngularJS內(nèi)置指令的使用方法,非常詳細(xì),常用的一些指令操作都做了總結(jié),有需要的小伙伴參考下
    2015-02-02
  • Angular 4依賴注入學(xué)習(xí)教程之Injectable裝飾器(六)

    Angular 4依賴注入學(xué)習(xí)教程之Injectable裝飾器(六)

    這篇文章主要給大家介紹了關(guān)于Angular 4依賴注入之Injectable裝飾器的相關(guān)資料,文中介紹的非常詳細(xì),對(duì)大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來跟著小編一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-06-06
  • angularJS 中$attrs方法使用指南

    angularJS 中$attrs方法使用指南

    這篇文章主要介紹了angularJS 中$attrs方法使用指南,需要的朋友可以參考下
    2015-02-02
  • angular組件間傳值測(cè)試的方法詳解

    angular組件間傳值測(cè)試的方法詳解

    這篇文章主要給大家介紹了關(guān)于如何測(cè)試angular組件間傳值的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用angular組件具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-05-05
  • AngularJS中使用HTML5手機(jī)攝像頭拍照

    AngularJS中使用HTML5手機(jī)攝像頭拍照

    這篇文章主要介紹了AngularJS中使用HTML5手機(jī)攝像頭拍照的相關(guān)資料,需要的朋友可以參考下
    2016-02-02
  • 詳解Angularjs filter過濾器

    詳解Angularjs filter過濾器

    這篇文章主要介紹了angularjs filter過濾器的相關(guān)資料,需要的朋友可以參考下
    2016-02-02
  • AngularJS?的生命周期和基礎(chǔ)語(yǔ)法使用詳解

    AngularJS?的生命周期和基礎(chǔ)語(yǔ)法使用詳解

    當(dāng)你在輸入框中鍵入文本時(shí),這個(gè)文本會(huì)立即反映到?testString?屬性上,反之亦然,如果你在組件類中改變?testString?的值,輸入框的內(nèi)容也會(huì)相應(yīng)更新,這篇文章主要介紹了AngularJS?的生命周期和基礎(chǔ)語(yǔ)法,需要的朋友可以參考下
    2024-05-05
  • 使用angular-cli webpack創(chuàng)建多個(gè)包的方法

    使用angular-cli webpack創(chuàng)建多個(gè)包的方法

    這篇文章主要介紹了使用angular-cli webpack創(chuàng)建多個(gè)包的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-10-10
  • AngularJS的Filter的示例詳解

    AngularJS的Filter的示例詳解

    本文通過示例給大家詳解angularjs 的filter知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧
    2017-03-03

最新評(píng)論

北票市| 新干县| 辽宁省| 清河县| 灌云县| 连江县| 远安县| 封开县| 马尔康县| 海原县| 温泉县| 阳高县| 同江市| 五原县| 宁夏| 石嘴山市| 昂仁县| 达尔| 泾源县| 望谟县| 潍坊市| 鹤壁市| 方正县| 收藏| 牟定县| 八宿县| 利津县| 湘西| 稻城县| 莱芜市| 孟连| 云梦县| 三江| 文成县| 威宁| 峡江县| 民勤县| 望江县| 宁强县| 肇东市| 广水市|