Angular搜索 過濾 批量刪除 添加 表單驗(yàn)證功能集錦(實(shí)例代碼)
廢話不多說了,直接給大家貼代碼,具體代碼如下所示;
<!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">
<div style="width: 1000px">
<input type="text" placeholder="用戶名搜索" ng-model="yhmss"/>
<input type="text" placeholder="手機(jī)號(hào)搜索" ng-model="sjhss"/>
<select ng-model="Choicecity">
<option>選擇城市</option>
<option>北京</option>
<option>上海</option>
<option>天津</option>
<option>重慶</option>
</select>
<select ng-model="Choicestate">
<option>選擇狀態(tài)</option>
<option>發(fā)貨</option>
<option>已發(fā)貨</option>
</select>
<select ng-model="Choiceorder">
<option>開始月份</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
-
<select>
<option>結(jié)束月份</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
</div>
<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('id')" class="sspan">排序</button></th>
<th>商品名</th>
<th>用戶名</th>
<th>手機(jī)號(hào)</th>
<th>價(jià)格<button ng-click="sort('price')" class="sspan">排序</button></th>
<th>城市</th>
<th>下單時(shí)間<button ng-click="sort('order')" class="sspan">排序</button></th>
<th>狀態(tài)</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>
<div ng-show="tj" style="margin-left: 200px" >
<h1>添加</h1>
<form name="registerForm" novalidate>
<div id="email-group">
<label for="email">E-mail:</label> <input type="email" class="form-control" ng-model="email" name="email" id="email" placeholder="請(qǐng)輸入電子郵箱..." required>
<p>
<span style="color: red" ng-show=" registerForm.email.$invalid">
<span ng-show="registerForm.email.$error.required">*請(qǐng)輸入郵箱</span> <span
ng-show="registerForm.email.$error.email">*請(qǐng)輸入正確的email地址</span>
</span>
</p>
</div>
<div id="name-group">
<label for="name">昵稱:</label> <input type="text" class="form-control" ng-model="name" name="name" id="name" placeholder="請(qǐng)輸入昵稱..." required>
<p>
<span style="color: red" ng-show="registerForm.name.$invalid">
<span ng-show="registerForm.name.$error.required">*請(qǐng)輸入姓名</span>
</span>
</p>
</div>
<div 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="請(qǐng)輸入密碼..." required>
<p>
<span style="color: red" ng-show="registerForm.password.$invalid">
<span ng-show="registerForm.password.$error.minlength">*密碼長(zhǎng)度不小于6</span>
<span ng-show="registerForm.password.$error.maxlength">*密碼長(zhǎng)度不超過20</span>
</span>
</p>
</div>
<div id="passwordagaingroup">
<label for="passwordagain">再輸入一遍密碼:</label> <input type="password"
class="form-control" ng-model="passwordagain" name="passwordagain"
id="passwordagain" placeholder="請(qǐng)?jiān)佥斠槐槊艽a..." required>
<p>
<span style="color: red" ng-show="registerForm.password.$valid">
<span ng-show="passwordagain!=password">*兩次密碼輸入不一致</span>
</span>
</p>
</div>
<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>
</div>
</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:"發(fā)貨",
done:false
},
{ commodity:"小米6",
name:"李四",
phone:15222222,
price:2999,
city:"北京",
order:"8-2",
state:"發(fā)貨",
done:false
},
{ commodity:"華為P9",
name:"王五",
phone:153333333,
price:3999,
city:"上海",
order:"9-3",
state:"已發(fā)貨",
done:false
},
{ commodity:"OPPO R11",
name:"趙六",
phone:15444444,
price:4999,
city:"天津",
order:"9-4",
state:"已發(fā)貨",
done:false
},
{ commodity:"ViVo",
name:"錢七",
phone:155555555,
price:2999,
city:"重慶",
order:"10-4",
state:"已發(fā)貨",
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 = "選擇狀態(tài)";
$scope.stateFun = function (item) {
if($scope.Choicestate != "選擇狀態(tài)"){
if(item.state == $scope.Choicestate){
return true;
}else {
return false;
}
}else {
return true;
}
};
$scope.pl = "已發(fā)貨";
$scope.fahuo = function (index) {
if($scope.data[index].state=="發(fā)貨"){
$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>
總結(jié)
以上所述是小編給大家介紹的Angular搜索 過濾 批量刪除 添加 表單驗(yàn)證功能集錦(實(shí)例代碼),希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- 淺析Angular19 自定義表單控件
- Angular4編程之表單響應(yīng)功能示例
- Angular實(shí)現(xiàn)表單驗(yàn)證功能
- AngularJS 表單驗(yàn)證手機(jī)號(hào)的實(shí)例(非必填)
- AngularJS實(shí)現(xiàn)的獲取焦點(diǎn)及失去焦點(diǎn)時(shí)的表單驗(yàn)證功能示例
- AngularJS表單驗(yàn)證功能
- AngularJS實(shí)現(xiàn)注冊(cè)表單驗(yàn)證功能
- angular4中關(guān)于表單的校驗(yàn)示例
- AngularJS實(shí)現(xiàn)表單驗(yàn)證功能詳解
- AngularJS實(shí)現(xiàn)表單元素值綁定操作示例
- Angular將填入表單的數(shù)據(jù)渲染到表格的方法
- Angular4表單驗(yàn)證代碼詳解
- angular動(dòng)態(tài)表單制作
相關(guān)文章
Angular4學(xué)習(xí)教程之HTML屬性綁定的方法
這篇文章主要給大家介紹了關(guān)于Angular4學(xué)習(xí)教程之HTML屬性綁定的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2018-01-01
Angularjs之如何在跨域請(qǐng)求中傳輸Cookie的方法
跨域傳輸Cookie是需要后臺(tái)和前臺(tái)同時(shí)做相關(guān)處理才能解決的,這篇文章主要介紹了Angularjs之如何在跨域請(qǐng)求中傳輸Cookie的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-06-06
AngularJS標(biāo)簽頁tab選項(xiàng)卡切換功能經(jīng)典實(shí)例詳解
這篇文章主要介紹了AngularJS實(shí)現(xiàn)標(biāo)簽頁tab選項(xiàng)卡功能,結(jié)合實(shí)例形式總結(jié)分析了各種常用的tab選項(xiàng)卡切換操作實(shí)現(xiàn)技巧與相關(guān)操作注意事項(xiàng),需要的朋友可以參考下2018-05-05
angularjs實(shí)現(xiàn)table增加tr的方法
下面小編就為大家分享一篇angularjs實(shí)現(xiàn)table增加tr的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-02-02
使用angularjs創(chuàng)建簡(jiǎn)單表格
AngularJS提供豐富填寫表單和驗(yàn)證。我們可以用ng-click來處理AngularJS點(diǎn)擊按鈕事件,然后使用 $dirty 和 $invalid標(biāo)志做驗(yàn)證的方式。使用novalidate表單聲明禁止任何瀏覽器特定的驗(yàn)證。下面我們來看看如何使用angularjs創(chuàng)建簡(jiǎn)單表格2016-01-01
angularjs實(shí)現(xiàn)多選框分段全選效果實(shí)現(xiàn)
這篇文章主要為大家介紹了angularjs實(shí)現(xiàn)多選框分段全選效果實(shí)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-06-06
詳解基于Angular4+ server render(服務(wù)端渲染)開發(fā)教程
本篇文章主要介紹了詳解基于Angular4+ server render(服務(wù)端渲染)開發(fā)教程 ,具有一定的參考價(jià)值,有興趣的可以了解一下2017-08-08
AngularJs ng-route路由詳解及實(shí)例代碼
這篇文章主要介紹了AngularJs ng-route路由,這里整理相關(guān)資料及簡(jiǎn)單實(shí)例代碼,有興趣的小伙伴可以參考下2016-09-09
AngularJS實(shí)現(xiàn)路由實(shí)例
本文給大家分享的是使用angularjs路由框架實(shí)現(xiàn)的一個(gè)簡(jiǎn)單頁面跳轉(zhuǎn)功能,非常的實(shí)用,也很詳細(xì),有需要的小伙伴可以參考下2017-02-02

