<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'contoller.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="lesson01/angular.min.js"></script>
</head>
<body>
<!--
ng-controller 表示控制器的名称
-->
<div ng-app="myApp" ng-controller="myController" >
排序后的数组{{hobby|reverse|orderBy}}
</div>
</body>
<script type="text/javascript">
//获取到app对象module
var myApp=angular.module("myApp",[]);
myApp.controller("myController",function($scope){
$scope.hobby="23154";//这里用的一串字符串
})
//自定义过滤器 参数1表示过滤器名称 参数2表示调用过滤的方法
myApp.filter('reverse',function(){
return function(text){
//参数text就是过滤之前返回的值
var returnArr=[];
for(var i=text.length-1;i>=0;i--){
returnArr[returnArr.length]=text[i];
}
return returnArr;
}
})
</script>
</html>
AngularJs自定义过滤器
最新推荐文章于 2021-08-11 19:45:32 发布