HTML angular sorting, deleting, and blurring the contents of a table

Source: Internet
Author: User


<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<style>
table{border:1px solid Deepskyblue;}
</style>
<script type= "Text/javascript" src= "Angular.js" ></script>
<script>
var app = Angular.module (' MyApp ', []);
App.controller (' Myctrl ', function ($scope) {
$scope. Nc=function (name) {
$scope. Data.splice (name,1);
For (index in $scope. Data) {
if ($scope. data[index].name = = name) {
i = index;
$scope. Data.splice (index,1);
}
}
}

Delete all
$scope. dete= function () {
$scope. data = null;
}

$scope. Col = ' name ';//Sort by Name column by default
$scope. Gen = "";
$scope. desc = 0;//Default sort criteria Ascending
$scope. data = [{
Name:1,
Gender: ' OPPO ',
Age:26,
Score: ' Delete '
}, {
NAME:20,

Age:24,
Score: ' Delete '
}, {
Name:13,
Gender: ' Millet ',
AGE:20,
Score: ' Delete '
}, {
Name:4,
Gender: ' IPhone ',
Age:22,
Score: ' Delete '
}];
});

</script>
<body ng-app= "MyApp" ng-controller= "Myctrl" >
<input type= "text" placeholder= "Product name" ng-model= "Gen"/>
<input type= "button" value= "Delete all" ng-click= "dete ()"/>
<table border= "1px" cellspacing= "0px" >
<tr>
<th ng-click= "col= ' name ';d esc=!desc" > Product number </th>
<th ng-click= "col= ' gender ';d esc=!desc" > Product name </th>
<th ng-click= "col= ' age ';d esc=!desc" > Product price </th>
<th> Delete </th>
</tr>
<tr ng-repeat= "D in data| Filter:{gender:gen} |orderby:col:desc ">
&LT;TD ng-bind= "D.name" ></td>
&LT;TD ng-bind= "D.gender" ></td>
&LT;TD ng-bind= "D.age" ></td>
&LT;TD ng-bind= "D.score" ng-click= "NC (d.name)" ></td>
</tr>
</table>
</body>


HTML angular sorting, deleting, and blurring the contents of a table


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.