Home Web Front-end JS Tutorial Summary of Angular search, filtering and batch deletion functions

Summary of Angular search, filtering and batch deletion functions

Jan 02, 2018 pm 04:34 PM
angular delete batch

This article mainly introduces the collection of Angular search, filter, batch delete, and add form verification functions (example code). Friends who need it can refer to it. I hope it can help everyone.

Without further ado, I will post the code directly for you. The specific code is as follows;


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    .sspan{
      background: #28a54c;
      color: #fff;
      margin-left: 5px;
    }
    th,td{
      border: 1px solid #000;
      padding: 10px;
    }
    table{
      text-align: center;
      width: auto;
      border-collapse: collapse;
    }
    button{
      margin-top: 10px;
      margin-bottom: 10px;
    }
  </style>
</head>
<body ng-app="myapp" ng-controller="myCtrl">
  <p style="width: 1000px">
    <input type="text" placeholder="用户名搜索" ng-model="yhmss"/>
    <input type="text" placeholder="手机号搜索" ng-model="sjhss"/>
    <select ng-model="Choicecity">
      <option>选择城市</option>
      <option>北京</option>
      <option>上海</option>
      <option>天津</option>
      <option>重庆</option>
    </select>
    <select ng-model="Choicestate">
      <option>选择状态</option>
      <option>发货</option>
      <option>已发货</option>
    </select>
    <select ng-model="Choiceorder">
      <option>开始月份</option>
      <option>8</option>
      <option>9</option>
      <option>10</option>
    </select>
    -
    <select>
      <option>结束月份</option>
      <option>8</option>
      <option>9</option>
      <option>10</option>
    </select>
  </p>
  <button ng-click="tianjia()">新增订单</button>
  <button ng-click="plsc()">批量删除</button>
  <table>
    <thead>
    <tr style="background: #4404">
      <th><input type="checkbox" ng-model="checkAll" ng-click="quan()"/></th>
      <th>id<button ng-click="sort(&#39;id&#39;)" class="sspan">排序</button></th>
      <th>商品名</th>
      <th>用户名</th>
      <th>手机号</th>
      <th>价格<button ng-click="sort(&#39;price&#39;)" class="sspan">排序</button></th>
      <th>城市</th>
      <th>下单时间<button ng-click="sort(&#39;order&#39;)" class="sspan">排序</button></th>
      <th>状态</th>
    </tr>
    </thead>
    <tbody>
    <tr ng-repeat="item in data|filter:{name:yhmss}|filter:{phone:sjhss}|filter:cityFun|filter:stateFun|filter:orderFun|orderBy:cc:dd">
      <td><input type="checkbox" ng-model="item.done"/></td>
      <td>{{$index+1}}</td>
      <td>{{item.commodity}}</td>
      <td>{{item.name}}</td>
      <td>{{item.phone}}</td>
      <td>{{item.price}}</td>
      <td>{{item.city}}</td>
      <td>{{item.order}}</td>
      <td ng-click="fahuo($index)"> {{item.state}} </td>
    </tr>
    </tbody>
  </table>
  <p ng-show="tj" style="margin-left: 200px" >
    <h1>添加</h1>
    <form name="registerForm" novalidate>
      <p id="email-group">
        <label for="email">E-mail:</label> <input type="email" class="form-control" ng-model="email" name="email" id="email" placeholder="请输入电子邮箱..." required>
        <p>
          <span style="color: red" ng-show=" registerForm.email.$invalid">
            <span ng-show="registerForm.email.$error.required">*请输入邮箱</span> <span
              ng-show="registerForm.email.$error.email">*请输入正确的email地址</span>
          </span>
        </p>
      </p>
      <p id="name-group">
        <label for="name">昵称:</label> <input type="text" class="form-control" ng-model="name" name="name" id="name" placeholder="请输入昵称..." required>
        <p>
          <span style="color: red" ng-show="registerForm.name.$invalid">
            <span ng-show="registerForm.name.$error.required">*请输入姓名</span>
          </span>
        </p>
      </p>
      <p id="password-group">
        <label for="password">密码:</label> <input type="password" class="form-control" ng-model="password"
                             ng-minlength="6" ng-maxlength="20" name="password" id="password"
                             placeholder="请输入密码..." required>
        <p>
          <span style="color: red" ng-show="registerForm.password.$invalid">
            <span ng-show="registerForm.password.$error.minlength">*密码长度不小于6</span>
            <span ng-show="registerForm.password.$error.maxlength">*密码长度不超过20</span>
          </span>
        </p>
      </p>
      <p id="passwordagaingroup">
        <label for="passwordagain">再输入一遍密码:</label> <input type="password"
                                  class="form-control" ng-model="passwordagain" name="passwordagain"
                                  id="passwordagain" placeholder="请再输一遍密码..." required>
        <p>
          <span style="color: red" ng-show="registerForm.password.$valid">
            <span ng-show="passwordagain!=password">*两次密码输入不一致</span>
          </span>
        </p>
      </p>
      <button type="submit" class="btn btn-success" ng-click="tianjiapp()"
          ng-disabled="registerForm.email.$invalid || registerForm.name.$invalid || registerForm.password.$invalid || password != passwordagain">
        提交<span class="fa fa-arrow-right"></span>
      </button>
    </form>
  </p>
</body>
</html>
<script src="angular.js"></script>
  <script>
    var app = angular.module("myapp",[]);
    app.controller("myCtrl",function ($scope) {
      $scope.data = [
        {  commodity:"iPhone4",
          name:"张三",
          phone:151111111,
          price:4999,
          city:"北京",
          order:"8-1",
          state:"发货",
          done:false
        },
        {  commodity:"小米6",
          name:"李四",
          phone:15222222,
          price:2999,
          city:"北京",
          order:"8-2",
          state:"发货",
          done:false
        },
        {  commodity:"华为P9",
          name:"王五",
          phone:153333333,
          price:3999,
          city:"上海",
          order:"9-3",
          state:"已发货",
          done:false
        },
        {  commodity:"OPPO R11",
          name:"赵六",
          phone:15444444,
          price:4999,
          city:"天津",
          order:"9-4",
          state:"已发货",
          done:false
        },
        {  commodity:"ViVo",
          name:"钱七",
          phone:155555555,
          price:2999,
          city:"重庆",
          order:"10-4",
          state:"已发货",
          done:false
        }
      ];
      $scope.Choicecity = "选择城市";
      $scope.cityFun = function (item) {
        if($scope.Choicecity != "选择城市"){
          if( item.city == $scope.Choicecity){
            return true;
          }else {
            return false;
          }
        }else {
          return true;
        }
      };
      $scope.Choicestate = "选择状态";
      $scope.stateFun = function (item) {
        if($scope.Choicestate != "选择状态"){
          if(item.state == $scope.Choicestate){
            return true;
          }else {
            return false;
          }
        }else {
          return true;
        }
      };
      $scope.pl = "已发货";
      $scope.fahuo = function (index) {
        if($scope.data[index].state=="发货"){
          $scope.data[index].state =$scope.pl;
        }
      };
      $scope.Choiceorder = "开始月份";
      $scope.orderFun = function (item) {
        if($scope.Choiceorder != "开始月份"){
          var arr = $scope.order.split("-");
          var min = arr[0];
          var max = arr[1];
          if(item.order >= min){
            return false;
          }else {
            return true;
          }
        }else {
          return true;
        }
      }
      $scope.quan = function () {
        if($scope.checkAll == true){
          for(var i = 0 ; i <$scope.data.length ; i++){
            $scope.data[i].done = true;
          }
        }else{
          for(var i = 0 ; i <$scope.data.length ; i++){
            $scope.data[i].done = false;
          }
        }
      };
      $scope.plsc = function () {
        for(var i = 0 ; i <$scope.data.length ; i++){
          if($scope.data[i].done == true){
            $scope.data.splice(i,1);
            i--;
          }
        }
      };
      $scope.tj = false;
      $scope.tianjia = function () {
        $scope.tj = true;
      };
      $scope.error = false;
      $scope.tijiaola = function () {
        if($scope.commoditys==null||$scope.names==null||
          $scope.commoditys<6||$scope.commoditys.length>20){
          $scope.error = true;
        }
      };
      $scope.dd = false;
      $scope.cc = "id";
      $scope.sort = function (couldm) {
        if($scope.cc == couldm ){
          $scope.dd =! $scope.dd;
        }
        $scope.cc = couldm;
      }
      $scope.tianjiapp = function () {
        $scope.data.push({commodity:$scope.email,name:$scope.name,phone:$scope.password})
      }
    })
  </script>
Copy after login

Related recommendations:

Example of provincial and municipal secondary linkage function implemented by AngularJS

AngularJS implements input box word limit reminder function

AngularJS environment Building tutorial

The above is the detailed content of Summary of Angular search, filtering and batch deletion functions. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Can the inetpub folder be deleted? How to quickly delete the inetpub folder on the C drive Can the inetpub folder be deleted? How to quickly delete the inetpub folder on the C drive Mar 13, 2024 pm 02:00 PM

Can the inetpub folder be deleted? How to quickly delete the inetpub folder on the C drive

How to delete Xiaohongshu notes How to delete Xiaohongshu notes Mar 21, 2024 pm 08:12 PM

How to delete Xiaohongshu notes

What folder is found.000? Can the found.000 folder be deleted? What folder is found.000? Can the found.000 folder be deleted? Mar 13, 2024 pm 08:52 PM

What folder is found.000? Can the found.000 folder be deleted?

Is it true that you can be blocked and deleted on WeChat and permanently unable to be added? Is it true that you can be blocked and deleted on WeChat and permanently unable to be added? Apr 08, 2024 am 11:41 AM

Is it true that you can be blocked and deleted on WeChat and permanently unable to be added?

How to delete Xiaohongshu releases? How to recover after deletion? How to delete Xiaohongshu releases? How to recover after deletion? Mar 21, 2024 pm 05:10 PM

How to delete Xiaohongshu releases? How to recover after deletion?

What is hiberfil.sys file? Can hiberfil.sys be deleted? What is hiberfil.sys file? Can hiberfil.sys be deleted? Mar 15, 2024 am 09:49 AM

What is hiberfil.sys file? Can hiberfil.sys be deleted?

How to completely delete WeChat File Transfer Assistant_Introduction to how to close WeChat File Transfer Assistant How to completely delete WeChat File Transfer Assistant_Introduction to how to close WeChat File Transfer Assistant Mar 20, 2024 pm 08:31 PM

How to completely delete WeChat File Transfer Assistant_Introduction to how to close WeChat File Transfer Assistant

How to install Angular on Ubuntu 24.04 How to install Angular on Ubuntu 24.04 Mar 23, 2024 pm 12:20 PM

How to install Angular on Ubuntu 24.04

See all articles