AngularJS API

4、AngularJS过滤器

  使用一个管道符(|)添加到表达式和指令中

  例1、格式化字母转为大写

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>

<div ng-app="myApp" ng-controller="personCtrl">

<p>姓名为 {{ lastName | uppercase }}</p>
<input type="text" ng-model="lastName | uppercase"/>
</div>

<script type="text/javascript">
angular.module('myApp',[]).controller('personCtrl',function($scope){
    $scope.lastName='Joe';
});    
</script>

</body>
</html>
格式化为大写字母

相关文章: