Angularjs過濾器實(shí)現(xiàn)動(dòng)態(tài)搜索與排序功能示例
本文實(shí)例講述了Angularjs過濾器實(shí)現(xiàn)動(dòng)態(tài)搜索與排序功能。分享給大家供大家參考,具體如下:
利用angularjs實(shí)現(xiàn)動(dòng)態(tài)的插入以及利用過濾器進(jìn)行數(shù)據(jù)的搜索以及排序.
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>www.dbjr.com.cn AngularJS過濾器測(cè)試</title>
</head>
<body ng-controller="app">
<table>
<tr>
<td ng-click="sort('name')">姓名</td>
<td ng-click="sort('age')">年齡</td>
</tr>
<tr ng-repeat="arr1 in arr1">
<td>{{arr1.name}}</td>
<td>{{arr1.age}}</td>
</tr>
</table>
<input id="wei" type="text" ng-focus="concentrate()" >
<input type="button" ng-click="search()" value="搜索">
</body>
<script src="angular.min.js"></script>
<script src="jquery.js"></script>
<script>
// var wei = document.getElementById("wei");
// console.log(wei);
// setTimeout(function(){
// $("#wei").attr("disabled",false);
// },3000);
var m=angular.module("myApp",[]);
m.controller("app",["$scope","$filter",function($scope,$filter){
var arr=[
{"name":"豬","age":20},
{"name":"小豬","age":23},
{"name":"大貓","age":227},
{"name":"老虎","age":29},
{"name":"中虎","age":29},
{"name":"老虎","age":39},
{"name":"老貓","age":47},
{"name":"熊貓","age":29},
{"name":"樹懶","age":27},
{"name":"獅子","age":59}
];
$scope.arr1=arr;
//實(shí)現(xiàn)查詢功能
var isopen=true;
$scope.sort=function(str){
$scope.arr1=$filter("orderBy")($scope.arr1,str,isopen);
isopen=!isopen;
//console.log(isopen);
};
$scope.concentrate=function(){
console.log("已聚焦");
}
//實(shí)現(xiàn)查詢功能
$scope.search=function(){
console.log(11);
$scope.arr1=$filter("filter")(arr,document.getElementById("wei").value);
}
}]);
</script>
</html>
運(yùn)行效果:

更多關(guān)于AngularJS相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《AngularJS指令操作技巧總結(jié)》、《AngularJS入門與進(jìn)階教程》及《AngularJS MVC架構(gòu)總結(jié)》
希望本文所述對(duì)大家AngularJS程序設(shè)計(jì)有所幫助。
- Angularjs material 實(shí)現(xiàn)搜索框功能
- Angular實(shí)現(xiàn)跨域(搜索框的下拉列表)
- Angular實(shí)現(xiàn)搜索框及價(jià)格上下限功能
- Angularjs實(shí)現(xiàn)搜索關(guān)鍵字高亮顯示效果
- 在 Angular 中實(shí)現(xiàn)搜索關(guān)鍵字高亮示例
- angularjs實(shí)現(xiàn)搜索的關(guān)鍵字在正文中高亮出來
- angularjs實(shí)現(xiàn)分頁和搜索功能
- angularJs使用$watch和$filter過濾器制作搜索篩選實(shí)例
- Angular封裝搜索框組件操作示例
相關(guān)文章
Angular中使用Api 代理的實(shí)現(xiàn)
我們對(duì)接的過程中總是遇到跨域的問題,本文使用 angualr 來講解代理api對(duì)接的話題,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-04-04
Angularjs 1.3 中的$parse實(shí)例代碼
本文通過實(shí)例代碼給大家介紹了angularjs $parse的相關(guān)知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2017-09-09
angularjs學(xué)習(xí)筆記之簡(jiǎn)單介紹
這篇文章主要介紹了angularjs學(xué)習(xí)筆記之簡(jiǎn)單介紹的相關(guān)資料,需要的朋友可以參考下2015-09-09
Angularjs Ng_repeat中實(shí)現(xiàn)復(fù)選框選中并顯示不同的樣式方法
今天小編就為大家分享一篇Angularjs Ng_repeat中實(shí)現(xiàn)復(fù)選框選中并顯示不同的樣式方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-09-09
Angular 2 利用Router事件和Title實(shí)現(xiàn)動(dòng)態(tài)頁面標(biāo)題的方法
本篇文章主要介紹了Angular 2 利用Router事件和Title實(shí)現(xiàn)動(dòng)態(tài)頁面標(biāo)題的方法,具有一定的參考價(jià)值,有興趣的可以了解一下2017-08-08
spring+angular實(shí)現(xiàn)導(dǎo)出excel的實(shí)現(xiàn)代碼
這篇文章主要介紹了spring+angular實(shí)現(xiàn)導(dǎo)出excel的實(shí)現(xiàn)代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-02-02
AngularJS select設(shè)置默認(rèn)值的實(shí)現(xiàn)方法
這篇文章主要介紹了AngularJS select設(shè)置默認(rèn)值的實(shí)現(xiàn)方法的相關(guān)資料,這里提供實(shí)現(xiàn)方法幫助大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下2017-08-08

