<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>angular</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src=""></script>
<script src=""></script>
<link href="">
<script src="" type="text/javascript"></script>
</head>
<body ng-app="app">
<script type="text/javascript">
var app = angular.module("app",[]);
</script>
<div>
<div>
数据过滤器;
</div>
<div ng-controller="filte">
{{sourCode}}
<br>
{{sourCode | up}}
</div>
<script>
function filte($scope) {
$scope.sourCode = "hehe lala dudu oo zz";
};
app.filter("up" ,function() {
return function(ipt) {
return ipt.replace(/ (\w)/g,function($0,$1) {
return " "+$1.toUpperCase();
});
}
});
</script>
</div>
</body>
</html>
.factory工厂, $provider, service等等都是一样样的, 不要感觉很难, 其实就是看出一个数据模型或者实例就好了;:
复制代码 代码如下: