AngularJS 表达式中添加过滤器实例
过滤器可以通过一个管道字符(|)和一个过滤器添加到表达式中
历练实例:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible"content="IE=edeg" />
<meta name="viewport"content="width=device-width,initial-scale=1" />
<!--[if lt IE 9]>
<script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
<script src="http://apps.bdimg.com/libs/respond.js/1.4.2/respond.js"></script>
<![endif]-->
<title></title>
<meta charset="utf-8" />
<link rel="stylesheet"href="bootstrap-3.3.5/dist/css/bootstrap.min.css" />
</head>
<body>
<div class="container">
<div data-ng-app="myApp"data-ng-controller="myCtrl">
<p>格式化字符串</p>
<input type="text"data-ng-model="lang" />
<p>{{lang | uppercase}}</p><!--uppercase 过滤器将字符串格式化为大写:-->
<p>{{lang | lowercase}}</p><!--lowercase 过滤器将字符串格式化为小写:-->
</div>
</div>
<script src="jQuery/jquery-2.1.4.js"></script>
<script src="bootstrap-3.3.5/dist/js/bootstrap.min.js"></script>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script>
angular.module("myApp", []).controller("myCtrl", function ($scope) {$scope.lang="html5" })
</script>
</body>
</html>