<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="angular.js" ></script>
<script>
var app = angular.module("myApp",[]);
app.controller("myCtrl",function($scope){
$scope.haha = "hello,angular";
});
//调用filter()方法自定义过滤器
app.filter("myFilter",function(){
return function(text){
return text.replace(/hello/,"你好");
}
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<p>{{haha | myFilter}}</p>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="angular.js" ></script>
<script>
var app = angular.module("myApp",[]);
app.controller("myCtrl",function($scope){
$scope.haha = "hello,angular";
});
//调用filter()方法自定义过滤器
app.filter("myFilter",function(){
return function(text){
return text.replace(/hello/,"你好");
}
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<p>{{haha | myFilter}}</p>
</body>
</html>